Commit c8651a3
fix(coordinator): cache wait_for_signal_done timeouts via shared complete() path
`waitForSignalDone` had two terminal paths: the registered `wrapped`
resolver (which cleared the timer, wrote the replay cache, and
resolved) and the timeout callback (which removed the resolver,
finished the wait, but \*did not\* write the replay cache before
resolving). A client retry that reused the same requestId after a
timeout would therefore re-enter the wait path and register a fresh
resolver, inflating `activeSignalWaitCounts` and re-blocking the
coordinator's notification batching.
- Collapse both paths into a single idempotent `complete(result)` that
clears the timer, removes itself from `anySignalResolvers`, calls
`finishSignalWait`, writes the replay cache when `requestId` is set,
and resolves the promise. The `settled` guard makes repeated calls a
no-op so external callers can keep shifting the resolver out before
invoking it.
- Drop the now-redundant `finishSignalWait` calls in the three external
paths that consume a resolver (PTY exit, cleanupChildTask, signalDone)
— `complete` handles bookkeeping itself, so leaving the manual call
in place would double-decrement the wait count.
- In `unregisterCoordinator`, snapshot the resolvers before fan-out
because `complete` now splices itself from the live array.
- Add a coordinator.test.ts case: same requestId after a timeout
returns the cached timed-out result quickly instead of starting a
new live wait.
Addresses finding 1 of issue #157.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent ac031a7 commit c8651a3
2 files changed
Lines changed: 45 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5525 | 5525 | | |
5526 | 5526 | | |
5527 | 5527 | | |
| 5528 | + | |
| 5529 | + | |
| 5530 | + | |
| 5531 | + | |
| 5532 | + | |
| 5533 | + | |
| 5534 | + | |
| 5535 | + | |
| 5536 | + | |
| 5537 | + | |
| 5538 | + | |
| 5539 | + | |
| 5540 | + | |
| 5541 | + | |
| 5542 | + | |
| 5543 | + | |
| 5544 | + | |
| 5545 | + | |
5528 | 5546 | | |
5529 | 5547 | | |
5530 | 5548 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| 232 | + | |
| 233 | + | |
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
239 | | - | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| |||
1926 | 1927 | | |
1927 | 1928 | | |
1928 | 1929 | | |
| 1930 | + | |
1929 | 1931 | | |
1930 | 1932 | | |
1931 | 1933 | | |
1932 | 1934 | | |
1933 | 1935 | | |
1934 | 1936 | | |
1935 | 1937 | | |
1936 | | - | |
1937 | 1938 | | |
1938 | 1939 | | |
1939 | 1940 | | |
| |||
2227 | 2228 | | |
2228 | 2229 | | |
2229 | 2230 | | |
2230 | | - | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
2231 | 2236 | | |
2232 | 2237 | | |
2233 | 2238 | | |
| |||
2376 | 2381 | | |
2377 | 2382 | | |
2378 | 2383 | | |
| 2384 | + | |
2379 | 2385 | | |
2380 | 2386 | | |
2381 | 2387 | | |
2382 | 2388 | | |
2383 | 2389 | | |
2384 | 2390 | | |
2385 | 2391 | | |
2386 | | - | |
2387 | 2392 | | |
2388 | 2393 | | |
2389 | 2394 | | |
| |||
2529 | 2534 | | |
2530 | 2535 | | |
2531 | 2536 | | |
2532 | | - | |
2533 | | - | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
2534 | 2547 | | |
2535 | | - | |
2536 | | - | |
2537 | | - | |
2538 | | - | |
2539 | | - | |
2540 | 2548 | | |
2541 | 2549 | | |
2542 | | - | |
| 2550 | + | |
2543 | 2551 | | |
2544 | 2552 | | |
2545 | 2553 | | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
2546 | 2559 | | |
2547 | 2560 | | |
2548 | 2561 | | |
2549 | 2562 | | |
2550 | 2563 | | |
2551 | 2564 | | |
2552 | 2565 | | |
2553 | | - | |
| 2566 | + | |
2554 | 2567 | | |
2555 | 2568 | | |
2556 | 2569 | | |
2557 | 2570 | | |
2558 | 2571 | | |
2559 | 2572 | | |
2560 | 2573 | | |
2561 | | - | |
| 2574 | + | |
2562 | 2575 | | |
2563 | 2576 | | |
2564 | 2577 | | |
| |||
0 commit comments