Commit 793dfe5
committed
perf: signal readiness before running post-connect initialization work
handleAllConnected previously did its post-connect initialization work
(auto-discover networks, queue initial getall, set up periodic timers,
construct + trigger HA Discovery) and THEN signaled readiness at the end.
The auto-discovery step alone can take up to 5s (it has a 5s timeout
waiting for the tree command response). So users with autoDiscoverNetworks
enabled (the default) saw a 5s gap between connections coming up and the
bridge advertising itself as ready, even though all the connection-level
prerequisites were already satisfied.
Moves the readiness signal to fire as soon as connection health is
confirmed. The rest of the post-connect work runs after, in the same
async chain - the production caller (cgateWebBridge#_handleAllConnected)
already doesn't await this function, so the work proceeds in the
background. Tests still await the function and observe all work
completing.
Net: ~up-to-5s faster ready-signal-to-wire latency for users with
auto-discovery; no behaviour change for the work itself or its ordering
within the function. Regression test asserts readiness fires before
both the command-queue add and the discovery trigger.1 parent 788a5d2 commit 793dfe5
2 files changed
Lines changed: 39 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
26 | 36 | | |
27 | 37 | | |
28 | 38 | | |
| |||
65 | 75 | | |
66 | 76 | | |
67 | 77 | | |
68 | | - | |
69 | 78 | | |
70 | 79 | | |
71 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
430 | 459 | | |
431 | 460 | | |
432 | 461 | | |
| |||
0 commit comments