Repository navigation
fix(wsl): run wsl.exe probes from the system folder, never the profile - #29853
Conversation
Reverts #29845's extended EBUSY retry: wsl.exe no longer runs in the profile, so nothing outside the test's process tree holds it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
|
CI evidence that the profile hold is gone (and #29845's wait can go)
Before this change, 11 of 30 runs failed on the hold (#29845). Eight clean runs in a row would happen about 1% of the time if the hold were still there (0.55^8). The real-distro lanes also passed ( |
ELI5
On Windows, Orca asks WSL questions (which Linux distros are running, where
gitlives, and so on) by runningwsl.exe. Eachwsl.exehas to be started from some Windows folder. Orca was starting it from its own profile folder. WSL then keeps that folder in use for about a minute after the question is answered, so the profile folder can't be deleted during that minute. Orca now startswsl.exefrom the Windows system folder (C:\Windows), which nobody ever needs to delete.What Changed
Before: an
orca serverun with a temporary profile on a Windows machine that has WSL left a profile folder that could not be deleted for about 60 seconds after serve exited ("resource busy or locked"). On Windows ARM CI this failed the serve-parity test, until #29845 made the test wait out the minute.After:
wsl.exenever runs from a profile or user folder, so the profile folder can be deleted as soon as Orca exits.Mechanism:
resolveWslInteropSpawnCwd()(the shared "which folder shouldwsl.exestart in" answer) used to preferORCA_USER_DATA_PATH(the profile), thenUSERPROFILE/home. It now picks%SystemRoot%, then%windir%,%SystemDrive%\, andC:\. Every caller of the helper changes with it, including the running-distro probe that fix(orcad): orca serve owns its Claude and Codex accounts again #29209's account service runs at orcad startup, the WSL availability check, the git runner, the hook relay, the file watcher, and the\\wsl$delete path.codex-fetcher.ts) startedwsl.exein<profile>/rate-limit-pty-cwd. The WSL branch now uses the helper. The guest side alreadycds to its own temp folder, so nothing inside Linux changes. The host Codex branch keeps its bounded folder.Argv building is unchanged (
buildWslExecArgsetc.). Only the Windows working directory handed toCreateProcessWchanged.Why
#29845's investigation traced the hold here. It started when #29209 merged. It only happens on runners where the startup probe runs
wsl.exe. It outlives every process in the test's tree, and it lasts about as long as WSL's idle timeout.wsl.exeturns its Windows working directory into the Linux starting directory (/mnt/c/...), and WSL keeps that open until the instance idles.Alternatives considered:
--cd ~towsl.exe: this changes the Linux side's directory only. The Windows-side working directory is still handed toCreateProcessW, so that is still the folder held.The system folder always exists, is never deleted, and is the directory Windows services start in. It also keeps #16463's guarantee that
wsl.exenever inherits a deleted\\wsl.localhost\...directory. All of these commands already carry their Linux directory explicitly (git -C,cdinsidesh -c), so none of them relied on the starting folder.Linked Issue
N/A (maintainer fix). Root cause found in #29845. Regression from #29209.
Visual Proof
N/A. This changes the background process working directory, with no UI.
Testing
src/main/wsl-interop-spawn-directory.test.ts: the helper names the system root even when the profile and the user folder exist, never falls back to either, skips a missing candidate, and re-validates its memo.src/main/wsl-running-distros.test.ts: the startupwsl --list --runningprobe runs withcwdset to the system root, not the profile.codex-fetcher.test.ts,wsl.test.ts,wsl-runner.test.ts,wsl-unc-delete.test.tsnow assert the exact neutral directory.Windows CI:
orcad-serve-parity.integration.test.tsruns without the 75s hold on windows-11-arm. Results across repeated runs are in the comments below.pnpm tc:node,check:code-quality:changed, and vitest onsrc/main/{wsl,git,gitlab,codex,codex-accounts,claude-accounts,rate-limits,agent-hooks,daemon,ipc,providers,ai-vault,opencode,native-chat,text-generation}pass locally on macOS. The only failures are the browser-manager suites, which needORCA_BACKGROUND_LAUNCH=1and fail on main too.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
C:\Windowsis only writable by admins, so it is a safer working directory than a user-writable profile.wsl.exe. On macOS and Linux the helper's answer is unused.wsl.exespawns.C:\Windowscan't be translated to a Linux path, but neither could the profile path before, so behavior there is unchanged.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)