π fix(stryker): the mutation lanes keep each suite's whole TAP stream on Linux
Slice: #651
Part of #580. Since #643, stryker/lane.mjs runs each suite with --test-force-exit. On Linux that ends the process while stdout still holds the tail of the TAP stream (nodejs/node#67149). The fix, nodejs/node#67160, is in no 24.x release yet.
Stryker's tap runner reads a cut stream as a failed test file with no test named. On CI that:
- refused the src lane on #644 (
renumber-doc.test.ts), #645 (review-thread.test.ts, run 45650183390) and #646 (asks.test.ts); - can count a survivor as Killed.
What changes
stryker/drain-exit.cjsis a preload, loaded after Stryker's hook. It holdsprocess.exituntilprocess.stdouthas written what it holds, as nodejs/node#67160 does in core.- The exit's arguments pass through as given, so a failing suite keeps its exit code.
- A second call, or a call while stdout is destroyed or empty, exits at once.
- A comment names nodejs/node#67149, so the preload can be dropped once niyam's Node carries the fix.
stryker/lane.mjsadds-r <absolute path to drain-exit.cjs>tonodeArgs.--test-force-exitstays, so a mutant that leaves a server or timer open still ends at once instead of costing a timeout retry.src/stryker-lane.test.tsruns generated suites with the lane's ownnodeArgs, the way the tap runner spawns them. It reads stdout only once the child signals on fd 3: a generated suite signals once its tests have run, and a plain script signals as it callsprocess.exit. So the pipe has always backed up by then. The test checks five things:- the whole TAP stream arrives, through to its last summary line;
- a suite that leaves a timer open still ends;
- a failing suite keeps exit code 1;
process.exit(7)after 1 MB of queued stdout exits 7 with every byte written;- Stryker's hook still writes its report.
No new dependency, no guard file, and no // Stryker disable.
Evidence
The Linux measurement used the node:24 image (v24.22.3) as a non-root user with no network. It replays the tap runner's spawn (Stryker's hook, stdout piped into tap-parser with bail) 100 times per suite:
| Suite | main (--test-force-exit alone) | this branch (the lane's nodeArgs) |
|---|---|---|
src/review-thread.test.ts | 10 of 100 cut | 0 of 100 |
src/renumber-doc.test.ts | 3 of 100 cut | 0 of 100 |
Every cut run exited 0 with no plan line, partway through the stream: 3 or 5 of 8 tests in review-thread.test.ts.
src/stryker-lane.test.ts:
- macOS, with the preload: 5 of 5 pass.
- macOS, preload removed: fails. The
exits.mjscase never exits. - Linux, with the preload: 5 of 5 pass.
- Linux, preload removed: fails.
exits.mjsloses its output every time, and the TAP-stream case stopped at 271 of 300 tests on some runs.
pnpm check exits 0 on this branch: pnpm test passes 2481 of 2481, pnpm test:scripts 138 of 138, and typecheck, lint, pins, pariksha, hooks, build and smoke all pass. The pre-push hook ran on the push.
CI's Mutation check passes on both heads, but it proves nothing here: this pull request changes no mutated source, so the src lane judged 0 killed of 0. The proof is the Linux replay above. The first sweep pull request after this merges runs the real lane in CI with the preload.
Cubic's review (fixed in 09133c7, both threads answered):
- After stdout drains, the held exit now calls
exit(...args), so code that setsprocess.exitCodewhile it waits can't change the exit code.exits.mjssetsexitCode = 3afterprocess.exit(7)and expects 7. The old callback gave 3. - A test child that hits the deadline is now killed rather than unref'd.
π€ Generated with Claude Code