You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A dispatcher-exec.test.ts stalled-delivery test passes against a broken runner when its child starts more than 600 ms late #1996
src/daemon/dispatcher-exec.test.ts:691 ("delivers every chunk in full, in order, even when one delivery stalls past the exit grace window") waits a fixed 600 ms, then checks that device.exec has not settled. If its child starts later than that, nothing has been delivered yet, so the check proves nothing. The product is correct; not seen on a real run.
Shown by breaking src/ports/node-process-runner.ts so it settles with a delivery pending (settleWhenDrained ignores #pendingDeliveries), with the child waiting before its first statement:
child delayed 0 ms: AssertionError: device.exec resolved while a chunk's delivery was still pending
child delayed 700 ms: 1 passed
child delayed 1500 ms: 1 passed
Seen on: test output with a slowed child, not a real run. The runner is correct.
Confirmed, with the reporter's three outputs. On bug/1996-repro the existing test, now titled "delivers every chunk in full, in order, even when the child starts late and one delivery stalls past the exit grace window", delays its child 700 ms and asserts what its settle check depends on. It fails every run:
Defect in the test. src/daemon/dispatcher-exec.test.ts:691 on main sleeps 600 ms from the dispatch, but the 300 ms grace starts at the child's exit. New: :672 is a second race, which fails a correct runner. The chunks are 20 ms apart, so a busy event loop reads both as one:
In this test file only: the child writes its second chunk once the test has the first, and the 600 ms start at the child's exit.
constprocessRunner=newNodeProcessRunner({exitDeferralCapMs: 30_000,exitGraceMs: 300});constspawned=vi.spyOn(processRunner,"spawnStreaming");// child: write A; setTimeout(() => process.exit(1), 15_000) as orphan guard;// every 10 ms: if the `go` file exists, write B and process.exit(0)awaitvi.waitFor(()=>expect(seen).toEqual(["before-exit-A"]),{interval: 10,timeout: 10_000});writeFileSync(go,"");const{ pid }=spawned.mock.results[0]?.valueas{readonlypid: number};awaitvi.waitFor(()=>expect(supervisor.isAlive(pid)).toBe(false),{interval: 10,timeout: 10_000});awaitnewPromise((resolve)=>setTimeout(resolve,600));/* the settle check and the rest, unchanged; remove the folder in finally */
reproduction with the fix: 34 passed, 3 of 3
fix: 34 passed, 5 of 5; child 0, 700, 3000 ms late: passed; event loop blocked 1500 ms: passed
src/daemon 894 passed; pnpm test:changed 34 passed; pnpm typecheck clean
broken runner, with the fix (child 0 and 700 ms late; the first also 3000 ms):
settleWhenDrained ignores pending deliveries device.exec resolved while a chunk's delivery was still pending
exit grace ignores them the same
close ignores them the same
exit grace ignores them, at 500 ms the same
drops chunks while a delivery is pending expected [ 'before-exit-A' ] to deeply equal [ …, 'before-exit-B' ]
Alternatives rejected
A longer sleep: still a race with the host.
Waiting for the first chunk only: the grace starts at the exit, and the chunks can still merge.
Faking setTimeout: the pid can be gone before the runner arms its grace (Windows), so one advance may miss it.
Risk
The 600 ms sleep is real. A correct runner never settles in it, so a slow host cannot fail it; a broken one's 300 ms timer is due first on the same event loop.
The raised cap keeps a slow host from failing the pending delivery.
Windows and the commit hook were not run on the fix.
Activity
V3RON commentedon Nov 30, 2026
Reproduction
Seen on: test output with a slowed child, not a real run. The runner is correct.
Confirmed, with the reporter's three outputs. On
bug/1996-reprothe existing test, now titled "delivers every chunk in full, in order, even when the child starts late and one delivery stalls past the exit grace window", delays its child 700 ms and asserts what its settle check depends on. It fails every run:Root cause
Defect in the test.
src/daemon/dispatcher-exec.test.ts:691on main sleeps 600 ms from the dispatch, but the 300 ms grace starts at the child's exit. New::672is a second race, which fails a correct runner. The chunks are 20 ms apart, so a busy event loop reads both as one:Simplest fix
In this test file only: the child writes its second chunk once the test has the first, and the 600 ms start at the child's exit.
Alternatives rejected
setTimeout: the pid can be gone before the runner arms its grace (Windows), so one advance may miss it.Risk
Fast track
Side findings
Written by an agent.
V3RON commentedon Nov 30, 2026
Delivery run
Merged: #2001 (#1996)
Written by an agent.
fix(test): the stalled-delivery exec test no longer passes when its c…