Commit 2b67bf0
authored
Implement find() wait and RECONNECT structure event (#24)
find() now waits for the target app to appear instead of failing
immediately. subscribeToStructure fires RECONNECT (2) when an app
reappears after being removed, distinguishing restarts from first-time
appearances.
Changes:
- find() waits indefinitely by default; { timeout: N } limits the wait;
{ timeout: 0 } preserves the old immediate-fail behavior
- find() works without prior root() call (triggers connection internally)
- close() is terminal: sets isClosed flag, rejects pending find() waiters,
prevents reconnection after close
- RECONNECT constant (2) added alongside ADD (1) and REMOVE (0)
- Per-app lifecycle via announceApp/unannounceApp: each app is tracked
independently, fixing the bug where one sibling disconnecting lost
all sibling connections
- Subscription keepalive via inactivityResendInterval field
- Per-listener event dedup with composite keys and history wait window
- Value dedup via per-node timestamp tracking
- Exponential backoff with jitter for reconnection
- Stall detection: force reconnect after prolonged server silence
with active subscriptions
- Direct mode sibling discovery uses server-pushed
eStructureChangeResponse instead of client-side polling
- CDP_FORCE_DIRECT_MODE=1 env var to force direct mode on proxy-capable
servers (for testing)
- Cache key fix: use join('.') instead of toString() for correct
invalidateApp prefix matching on app structure changes
- Remove unused serviceId storage on proxy connections
- Fix instanceId serialization: pass through as-is instead of defaulting
falsy values to 0
- appAddress() helper for DRY server address construction
- README updated with Structure Events section and find() options
- Version bump to 3.0.0 (breaking: find() default changed from
immediate fail to indefinite wait)
CDP-60691 parent ea72cfd commit 2b67bf0
5 files changed
Lines changed: 551 additions & 83 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
64 | 101 | | |
65 | 102 | | |
66 | 103 | | |
| |||
325 | 362 | | |
326 | 363 | | |
327 | 364 | | |
328 | | - | |
329 | | - | |
| 365 | + | |
| 366 | + | |
330 | 367 | | |
331 | 368 | | |
332 | 369 | | |
333 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
334 | 375 | | |
335 | 376 | | |
336 | 377 | | |
337 | 378 | | |
338 | 379 | | |
339 | | - | |
| 380 | + | |
340 | 381 | | |
341 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
342 | 385 | | |
343 | | - | |
| 386 | + | |
344 | 387 | | |
345 | | - | |
| 388 | + | |
346 | 389 | | |
347 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
348 | 396 | | |
349 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
350 | 401 | | |
351 | | - | |
352 | | - | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
353 | 405 | | |
354 | 406 | | |
355 | 407 | | |
| |||
604 | 656 | | |
605 | 657 | | |
606 | 658 | | |
607 | | - | |
608 | | - | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
609 | 662 | | |
610 | 663 | | |
611 | 664 | | |
| |||
0 commit comments