Repository navigation
fix(wsl): show a stopped WSL host within a second of its stop, never exec-ing into it - #35823
Conversation
…exec-ing into it After a watch or holder exit, a distro the running list still names is usually stopping. Liveness now re-reads only the running list (never boots) once a second for up to 5 s before any identity exec, and publishes distro-stopped as soon as the list drops it. An exit that arrives during a recovery backoff ends that recovery so the exit re-checks at once (E9).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
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. Comment |
[Medium impact] The changes affect WSL Orcad supervision and the timing of WSL host status updates. Fix the overlapping-exit case before merging, because Orca can still run a command inside a stopping distro. Findings
SummaryThis PR adds a short running-list poll after WSL holder or watch exits.
|
| running = await args.readRunning({ | ||
| distro: args.distro, | ||
| exitedAt: args.exitedAt, | ||
| probedAfter: args.now() |
There was a problem hiding this comment.
If the watch exits first and the holder exits near the stopping window's end, this poll keeps the first exit's exitedAt and deadline. A clean holder exit does not update the shared gate's stop time either. The final poll can accept a still-listed distro before the newer exit settles, then call readIdentity while it is stopping. That command can restart the distro the user just stopped.
Restart or supersede the current check when another exit arrives, and use the latest exit time before collecting guest evidence.
Flag-off: WSL hosts only (flag on). The default bridge is unaffected.
User-risk: Low.
wsl.exeprobes are made.ELI5
When you stop a WSL distro yourself (for example with
wsl --terminate), Orca should say "Ubuntu is stopped" right away. Sometimes it took up to 30 s, because Orca ran a command inside the distro to double-check while Windows still listed it as running. That check was slow to fail, and it retried on a growing delay. Now Orca waits for Windows' running list to drop the distro and checks it once a second, which is cheap and never starts the distro. A command that runs inside a distro while it is still stopping can start it again, so this also removes that risk.What Changed
wsl --list --running. If the distro was still listed, as one that is still stopping can be, the supervisor ran the guest identity check (wsl.exe --exec, 10 s timeout).unverifiable, which then retried after 1, 2, 4, 8 and 16 s, capped at 30 s.distro-stoppedstatus, waited for whichever retry first saw the list drop the distro.wsl-orcad-liveness-stopping-poll.ts, used fromWslOrcadLivenessSupervisor.run()for every holder or watch exit):probedAfteronreadRunning, combined with the settle anchor in the wiring), so a cached list can't answer.distro-stoppedand is published.noteSupervisedExitwakes the wait and supersedes the recovery's generation). The pending exit then re-reads the list immediately, instead of waiting behind a backoff of up to 30 s.running-list-unavailable);Why
wsl --list --runningreads per exit event, and none while the distro is running. An exec into the distro is both slow to fail and an E9 hazard.Linked Issue
Internal WSL tracker, E9; device notes from wsl-verify-7 (v18 and v2: the chat notice took up to about 30 s). The next device pass logs status publishes and list drops with timestamps.
Visual Proof
N/A in this PR. The device pass will time the notice.
Testing
New supervisor tests. Each fails with its change reverted (the poll, or the busy-entry wake):
distro-stoppedis published within one poll of the list dropping it.distro-stoppedabout 0.6 s after the exit.Wiring test: each stopping-window poll asks for a probe started after
probedAfter, never older than the exit's settle anchor.Four existing supervisor tests now advance through the stopping window. Their verdicts are unchanged.
Also run:
pnpm tc,typecheck:ci,check:code-quality:changed, the anti-slop lint, oxlint and the ast-grep gates.Not run on Windows.
Review
Agent skill upstream boundary
Notes
live/unverifiable/exited). A still-listed distro is never called stopped; the change only waits for the list.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)