Repository navigation
test(sdk): settle health-check commands before the next exec test starts - #4881
Dominion5254 wants to merge 1 commit into
Conversation
Since #4855, HealthDaemon.term() returns without awaiting an in-flight ready.fn. "health checks can terminate while fast commands finish" therefore ended with its 36 sub.exec calls still waiting on readFile. They spawned after the next test pointed the cp.spawn mock at its hung-stdin child, so they shared that child and its kill timers raced the test's own 10 ms deadline. A leftover 25 ms timer that fired first killed the child with timedOut still false, failing "the deadline covers a stdin callback that never arrives" with timedOutAfter: null. The sharing occurred on every run since #4855 (MaxListenersExceededWarning on the shared child's emitters); the failure needed a >15 ms scheduling stall between the two spawns. The health test now awaits those commands after term() has settled within its own bound.
helix-white
left a comment
There was a problem hiding this comment.
Approved at 2cf57f322. The PR merges cleanly with master; no correctness findings.
After health termination stopped waiting for in-flight checks, this fixture's commands could spawn under the next test's mock. Retaining their promise before signaling entry, then awaiting it after the separately bounded termination, drains the batch without changing the termination contract. Both waits reuse the existing 250 ms helper. Production behavior is unchanged.
Implementation diff: +0 / −0 lines in 0 files (excludes lockfiles, tests, docs, release notes, and changelog).
Verification: CI passed all 418 SDK tests, including this lifecycle file, and 542 TypeScript start-core tests. Prettier and Formatting & Lockfiles passed. The author's recorded injected-stall and loaded-run comparisons distinguish the fix from baseline. I did not run builds or tests during review.
Still pending: Build (aarch64/riscv64/x86_64), start-core Tests & Man Pages, StartWRT Tests, rpc-toolkit, visit-rs & backup-fs Tests, and Generated Bindings & MCP Catalog.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
This fix is now on |
Fixes an intermittent failure of
the deadline covers a stdin callback that never arrivesinprojects/start-sdk/lib/test/exec.lifecycle.test.ts. It shows up astimedOutAfter: nullwhere10was expected, e.g. on #4866 (job; a rerun passed).Cause
Since #4855,
HealthDaemon.term()returns without waiting for an in-flightready.fn. The preceding test,health checks can terminate while fast commands finish, therefore ended with its 36sub.execcalls still waiting onreadFile.The next test's
subject('hung-stdin')then pointed thecp.spawnmock at its hung child, so those leftover calls spawned that same child and attached their own 25 ms kill timers to it. Whenever a leftover timer fired before the test's own 10 ms deadline, it killed the child while the test'stimedOutflag was still false. That takes a stall of more than 15 ms between the two spawns, which a busy CI runner occasionally produces.The sharing itself happened on every run since #4855: each run prints
MaxListenersExceededWarningfor the shared child's emitters. Runs before #4855 print none.Change
The health test keeps the promise for its commands and awaits it after
term()has settled within its own bound. The test therefore still checks that stopping doesn't wait for the check, and it once again checks that the fast commands finish.Two alternatives were considered and rejected:
exec: fails every time.execspawns before it checks the signal, so leftover calls kill the next test's child immediately.Test-only. No user-visible behaviour changes, so there is no changelog fragment.
Verification
All on
2cf57f322, with0881e5430(its parent, currentmaster) as the baseline:0881e54302cf57f322exec(temporary branches)MaxListenersExceededWarningacross 30 runs of the fileWhere the leak started:
bf3c13a23^warns in 0 of 10 runs,bf3c13a23(#4855) in 10 of 10.make start-sdk-teston2cf57f322passes: 418/418 jest tests in 32 suites, 542/542 start-core tests, and the Node script tests, with no listener warnings. Prettier is clean.