Commit 4a7c6d4
committed
fix: Correct event handler ordering for dynamic printer connections
CRITICAL BUG FIX #2:
The previous commit (3910927) fixed the handler logic but introduced a new
initialization order bug that broke STARTUP connections.
PROBLEM:
Event handlers were registered AFTER connecting to printers, causing:
- connectPrinters() runs → backends emit 'backend-initialized'
- NO HANDLER REGISTERED YET → events lost
- Handlers registered after connection complete
- Result: NO MONITORS for startup connections (--last-used, --all-saved)
SOLUTION:
Moved event handler registration BEFORE connecting to printers:
CORRECT ORDER:
1. Initialize Spoolman tracker coordinator
2. Register event handlers (backend-initialized, connected) ← BEFORE connection
3. Connect to printers (events fire → handlers receive them)
4. Start WebUI
This ensures handlers are ready when backend-initialized events fire during
BOTH startup connections AND dynamic connections.
VERIFIED FLOWS:
✅ Startup: --last-used → handler receives events during connectPrinters()
✅ Startup: --all-saved → handler receives events during connectPrinters()
✅ Dynamic: API /api/printers/connect → handler already registered
✅ Dynamic: API /api/printers/reconnect → handler already registered
Step numbering updated to reflect new order (10, 11, 12, 13...).1 parent 3910927 commit 4a7c6d4
1 file changed
Lines changed: 25 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
| 380 | + | |
| 381 | + | |
403 | 382 | | |
404 | 383 | | |
405 | | - | |
| 384 | + | |
406 | 385 | | |
407 | 386 | | |
408 | 387 | | |
409 | 388 | | |
410 | 389 | | |
411 | 390 | | |
412 | | - | |
| 391 | + | |
413 | 392 | | |
414 | 393 | | |
415 | 394 | | |
| |||
456 | 435 | | |
457 | 436 | | |
458 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
| |||
0 commit comments