Skip to content

test(wsl): hand the reap test's fake cat its real stdin - #34352

Merged
nwparker merged 3 commits into
mainfrom
nwparker/bash-stdio-bridge-zombie-flake
Oct 27, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/bash-stdio-bridge-zombie-flake

Conversation

@nwparker

@nwparker nwparker commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2
Prod 0 0 0 0

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":

  • The fake cat used to start the real cat as realcat "$@" &. A non-interactive POSIX sh gives a background job /dev/null as stdin, and does so even with an explicit <&0 (dash, which is /bin/sh on 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.
  • The [ /dev/fd/0 -ef /dev/fd/3 ] && exit 0; sleep 30 scaffolding from test(wsl): make the bash relay reap test deterministic #34329 existed only to fake that blocking, so it's removed.
  • The 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/null EOF still let the relay kill the second fake cat before it started. On Linux (node:24-bookworm, dash, --cpus=2 plus 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 and check-changed-code-quality all pass.

  • Codex review is clean. An independent review approved; it confirmed the POSIX/dash /dev/null behaviour 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Test-only. The relay and its WSL/SSH behaviour are unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0100b449-d9ac-46df-ae26-832dd0deb315
Commits

Reviewing files that changed from the base of the PR and between f699660 and 5f25c2d.

Files selected for processing: 1
  • src/main/ssh/orcad-bash-stdio-bridge.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Walkthrough

The relay cleanup test stub now duplicates stdin to file descriptor 5 before starting cat in the background. It closes the duplicate descriptor, marks trap installation, and waits for cat. The stub no longer compares /dev/fd/0 with /dev/fd/3 or uses a 30-second sleep fallback.

Priority: Low

Merge Risk: Minimal · up to 5f25c

The test-only stdin handoff and cleanup change is ready to merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the test change: the WSL reap test's fake cat now receives its real stdin.
Description check Passed The description follows the template and clearly explains the failure, code change, rationale, testing, and scope. The separate linked-issue requirement remains unresolved.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 2dca6a8 into main Oct 27, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant