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
fix(wsl): reap the bash stdio relay's cats before it exits - #34260
Orca talks to its server inside a WSL distro through a small relay script. When a connection closed, the relay stopped one of its two helper processes and exited without collecting it. Inside WSL nothing else collects such leftovers, so a "dead but not gone" process stayed behind, and WSL counted the distro as still in use. The distro never shut down even when Orca had nothing running there.
What Changed
Before: the bash relay (#33820) ended with wait -n; kill $r $w; exit 0. One cat was killed and left unreaped. On WSL that zombie stays under the session's /init forever. The session never ends, so the distro, and the WSL virtual machine with its memory, stay up.
After:wait -n; kill $r $w 2>/dev/null; wait; exit 0. The relay waits for both cats before exiting, so nothing is left behind.
How it was found: the real-WSL lane's new idle-release phase in #33084 timed out on every distro, so I added diagnostics.
At the timeout, no Orca, holder or node process was left. The only thing remaining was an orphaned /init holding one [cat] <defunct>.
The zombie's start time matched the first bridge dial in a timed log of every guest command.
The one run where the race went the other way passed: the distro stopped 39 s after the last client, and the VM process dropped from 1.22 GB to gone.
Flag-off: the bash relay runs only for WSL hosts. Its only caller is the WSL branch of resolveOrcadStdioBridge (src/main/ssh/orcad-stdio-bridge.ts:38), and WSL hosts run only with ORCA_INTERNAL_WSL_HOSTS set. With the flag off it never runs, so users see no change.
Why
Reaping in the relay is the root fix. The alternatives treat symptoms:
killing WSL's session init would be invasive;
going back to the Node bridge gives up the ~45 MB saving per connection;
detaching the cats would still leave them for an init that never reaps.
N/A: there's no UI change. This is a process-lifecycle fix inside the WSL distro.
Testing
New behavioural test in orcad-bash-stdio-bridge.test.ts. A cat on PATH that takes 0.3 s to die after TERM leaves a mark when it does. orcad hangs up, and the relay must not exit before that mark exists. The test fails without the wait and passes with it.
The existing bash relay suite passes (byte-exact transfer, back-pressure both ways, teardown with no survivors).
The host-op byte budget and bridge resolution tests pass.
After wait -n returns, the Bash relay kills both cat processes and waits for them to be reaped before it exits. A test uses a cat wrapper with a delayed TERM handler and checks the bridge exit code and termination marker.
Priority: Normal
Merge Risk: Low · up to f379d
The cleanup appears sound, but its regression test should verify that the helper finishes before the relay exits. This is not a merge blocker.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: reaping the Bash stdio relay's cat processes before exit.
Description check
The description is mostly complete. It includes the required explanation, change details, rationale, testing, visual-proof status, scope notes, and checklist. It identifies the related WSL tracker and…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description is mostly complete. It includes the required explanation, change details, rationale, testing, visual-proof status, scope notes, and checklist. It identifies the related WSL tracker and #33084, although it does not provide an explicit Fixes issue link. Some full validation commands remain for CI.
Full details: Docstring Coverage
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. 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 2 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches: 💡 2
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
🛠️ Fix failing CI checks: 💡
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.
The relay killed the surviving cat and exited at once. WSL's per-session init never reaps
orphans, so that cat stayed a zombie, its session never ended, and the distro never stopped
even with nothing of Orca's left in it (seen on every real-WSL idle-release run). Wait for both
cats after the kill.
The test awaits exited before checking killed-cat. If the final relay wait is removed, the relay can exit before the delayed TERM trap creates the marker, and the later assertion can still pass. Hold the helper after creating the marker, assert that the relay is still running, then release it. Release the helper and terminate any unfinished child from finally so assertion failures do not leave the fixture running.
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: 6d242536-cb05-4944-9063-8a72a6996cc9
Commits
Reviewing files that changed from the base of the PR and between 2e1d149 and f379d3f.
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; 2 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Orca talks to its server inside a WSL distro through a small relay script. When a connection closed, the relay stopped one of its two helper processes and exited without collecting it. Inside WSL nothing else collects such leftovers, so a "dead but not gone" process stayed behind, and WSL counted the distro as still in use. The distro never shut down even when Orca had nothing running there.
What Changed
Before: the bash relay (#33820) ended with
wait -n; kill $r $w; exit 0. Onecatwas killed and left unreaped. On WSL that zombie stays under the session's/initforever. The session never ends, so the distro, and the WSL virtual machine with its memory, stay up.After:
wait -n; kill $r $w 2>/dev/null; wait; exit 0. The relay waits for bothcats before exiting, so nothing is left behind.How it was found: the real-WSL lane's new idle-release phase in #33084 timed out on every distro, so I added diagnostics.
/initholding one[cat] <defunct>.Flag-off: the bash relay runs only for WSL hosts. Its only caller is the WSL branch of
resolveOrcadStdioBridge(src/main/ssh/orcad-stdio-bridge.ts:38), and WSL hosts run only withORCA_INTERNAL_WSL_HOSTSset. With the flag off it never runs, so users see no change.Why
Reaping in the relay is the root fix. The alternatives treat symptoms:
cats would still leave them for an init that never reaps.Linked Issue
Internal WSL-via-orcad tracker R40 / E17 (blocks #33084).
Visual Proof
N/A: there's no UI change. This is a process-lifecycle fix inside the WSL distro.
Testing
New behavioural test in
orcad-bash-stdio-bridge.test.ts. Acaton PATH that takes 0.3 s to die after TERM leaves a mark when it does. orcad hangs up, and the relay must not exit before that mark exists. The test fails without thewaitand passes with it.The existing bash relay suite passes (byte-exact transfer, back-pressure both ways, teardown with no survivors).
The host-op byte budget and bridge resolution tests pass.
The zombie itself only appears under WSL's session init. The end-to-end proof is feat(wsl): let an idle WSL distro stop once its server idle-exits #33084's real-WSL idle-release phase, which carries this commit.
Automated tests added/updated
Notes
SSH hosts are unaffected: SSH Linux hosts use the Node bridge (
orcadPosixStdioBridgeCommand), not this relay.Checklist
N/Afor visuals with reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (typecheck, the touched tests and the changed-code gate pass locally; CI runs the rest)