Files
orca/config/scripts/orcad-distribution
Wooseong KimandNeil 18a5a94750 fix(wsl): stop launching wsl.exe when WSL is not installed (#40778)
* fix(wsl): stop launching wsl.exe when WSL is not installed

Windows 11's inbox wsl.exe opens the installer on every invocation. Remember a missing WSLService and LxssManager for this process so distro, status, and running probes do not retry.

* fix(wsl): only treat a missing service as no WSL, and refuse every wsl.exe spawn once known absent

sc.exe exits 1060 only when the service is not registered. Access denied, a
timeout or a signal kill now stay unknown instead of hiding a real install
until restart.

Once absence is confirmed, process-host refuses any wsl.exe spawn with ENOENT,
so per-distro background work (stale saved distros, hooks, git, watchers)
cannot reopen the installer either.

* fix(wsl): reuse an unknown WSL service answer for 60 s

Denied or timed-out sc.exe queries were not cached, so every running-list
read spawned another sc.exe pair even inside the wsl.exe failure backoff
(ten reads: twenty sc.exe). Unknown now holds for 60 s; confirmed absence
stays a session latch. Covers each service name alone reporting present.

* fix(wsl): never query WSL services synchronously

Sync distro and home reads now use the cached service verdict. Without one,
they return what is cached and start the async query rather than spawning
wsl.exe, so a sync read on startup can't open the installer either. The main
process starts the query at launch. List the new module in the web tsconfig.

* fix(wsl): keep sync WSL readers answering before the service verdict

Before the async sc.exe verdict, sync readers returned empty, so a default-WSL
Claude launch could pick host credentials and a daemon session could freeze
an undefined distro and skip the stopped-distro hold. They now check, once per
process and without spawning, for LxssManager.dll or wslservice.exe: present
keeps the previous sync wsl.exe path, absent returns empty. An expired unknown
verdict keeps being served while it re-checks.

* fix(wsl): read WSL service registration from the registry before sc.exe

The file-path hint missed Store MSIX and custom-INSTALLDIR layouts. Sync
readers now check HKLM\SYSTEM\CurrentControlSet\Services\{WSLService,
LxssManager} through the bundled in-process registry addon: a key proves the
service is registered (no sc.exe at all), while a missing key or unloadable
addon leaves the verdict to sc.exe's 1060, and sync readers spawn nothing
until then. Drops the sync-fs baseline entry. The stale-unknown re-check is now
an explicit peekWslInstallationAndRefreshIfDue.

* test(wsl): keep the sc.exe service-query suite independent of the host registry

On a Windows host with WSL installed, the real WSLService key answered before
the mocked sc.exe and failed 9 of the suite's tests. Mock the registry reader
as having no WSL keys. Also fix a stale function name in a comment.

---------

Co-authored-by: Neil <neil@stably.ai>
2026-11-16 17:59:37 -08:00
..