Repository navigation
test(wsl): hand the reap test's fake cat its real stdin - #34352
Conversation
The fake cat backgrounded the real cat with `&`, which a non-interactive sh starts on /dev/null (dash even under `<&0`). The socket reader therefore ended at once, before orcad hung up, and the relay killed its partner, sometimes before that cat's TERM trap was set: on Linux under load the trap count stayed at 1 even after #34329 (3 of 6 rounds of 50 failed). The fake cat now passes stdin on fd 5, as the relay itself does, so the socket reader ends only when orcad hangs up and the stdin reader blocks until killed.
…ridge-zombie-flake
|
No actionable comments were generated in the recent review.
|
ELI5
A test checks that the WSL stdio relay waits for a helper process it kills, so that no zombie is left behind. The test's fake helper accidentally read from an empty input, so it quit immediately instead of waiting like the real one. On a busy Linux CI machine, that early quit sometimes made the relay kill the second helper before the helper was ready to record that it had been killed, and the test failed even though the relay was fine. The fake helper now reads its real input.
What Changed
src/main/ssh/orcad-bash-stdio-bridge.test.ts> "waits for the cat it kills before exiting, so no zombie is left for the session init":catused to start the real cat asrealcat "$@" &. A non-interactive POSIX sh gives a background job/dev/nullas stdin, and does so even with an explicit<&0(dash, which is/bin/shon Linux CI). The fake now hands stdin over on fd 5 (exec 5<&0; realcat "$@" <&5 &), the same way the relay itself does with fd 4. The socket reader now ends only when orcad hangs up, and the stdin reader blocks until the relay kills it, as on a real host.[ /dev/fd/0 -ef /dev/fd/3 ] && exit 0; sleep 30scaffolding from test(wsl): make the bash relay reap test deterministic #34329 existed only to fake that blocking, so it's removed.trap.$$mark is now written after the child's PID is known, so the mark means "trap set and child known".The bridge is unchanged. It was correct; the failure was in the test's model of the cats.
Why
The test failed twice in a row on #34303 (run 40467002350, "tests node 24 1/5", "expected false to be true"). #34329 added a wait for both traps, but the early
/dev/nullEOF still let the relay kill the second fake cat before it started. On Linux (node:24-bookworm, dash,--cpus=2plus 4 busy loops), current main fails 3 of 6 rounds of 50 repeats with "expected 1 to be 2". A per-fake-cat trace showed the first fake cat's real cat ending with status 0 at once, and the second never starting. I didn't raise any timeouts or add retries.Linked Issue
N/A, CI flake from #34260 / #34329.
Visual Proof
N/A. Test-only change.
Testing
Linux, Docker as above: the fixed test passed 9 of 9 rounds of 50 repeats under CPU stress, against 3 of 6 rounds failing on main. The whole file passes (14 tests) without stress.
macOS: 50 of 50 repeats pass, and the whole file passes.
Mutation: removing the relay's post-kill
wait(fix(wsl): reap the bash stdio relay's cats before it exits #34260's fix) fails the test on Linux and macOS with "expected false to be true".pnpm tc:node, oxlint, oxfmt, ast-grep, the flaky-test ratchet andcheck-changed-code-qualityall pass.Codex review is clean. An independent review approved; it confirmed the POSIX/dash
/dev/nullbehaviour in a sandbox, and I applied its two P3 nits.Not changed: under that same 2.5x CPU oversubscription, "holds the desktop back, without buffering, while the desktop reads slowly" times out on main too, because its 30s flood can't finish. It passes without stress and isn't the reported flake.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Test-only. The relay and its WSL/SSH behaviour are unchanged.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)