From 0dbdd9f47f557c0b280097318c3e2464cb4f3e3b Mon Sep 17 00:00:00 2001 From: Josh Gratton Date: Mon, 18 May 2026 08:41:13 -0400 Subject: [PATCH] fix(web): keep auto-retrying when the WSL bootstrap hasn't appeared yet The auto-retry loop short-circuited the moment readBootstraps() returned no secondary entries. That looked right in isolation: "nothing pending, stop polling." But the desktop pool only publishes a backend's bootstrap once the backend's first start cycle has produced a config (see desktop.ipc.window.getLocalEnvironmentBootstraps's `Option.isNone(config) continue`), so a WSL backend mid-cold-boot is indistinguishable from "no WSL configured" from the renderer's side. The short-circuit fired before the WSL bootstrap got published, the loop stopped, and the env never registered. Drop the hasPendingSecondary gate. We still cap at the full backoff schedule (8 attempts, ~225s) and reconcileOnce is a no-op when every secondary is already registered, so the cost of running the budget out is a handful of cheap IPC calls. The payoff is that a WSL cold boot taking longer than the initial reconcile (which is the common case, not the exception) now actually gets caught. --- apps/web/src/environments/local/index.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/apps/web/src/environments/local/index.ts b/apps/web/src/environments/local/index.ts index abf2e3ef84..2869af29eb 100644 --- a/apps/web/src/environments/local/index.ts +++ b/apps/web/src/environments/local/index.ts @@ -252,19 +252,16 @@ async function reconcileOnce(): Promise { ); } -function hasPendingSecondary(): boolean { - const bootstraps = readBootstraps(); - for (const bootstrap of bootstraps) { - if (bootstrap.id === PRIMARY_LOCAL_ENVIRONMENT_ID) continue; - if (!findRecordByInstanceId(bootstrap.id)) return true; - } - return false; -} - function scheduleAutoRetry(): void { if (autoRetryHandle !== null) return; if (autoRetryAttempt >= AUTO_RETRY_DELAYS_MS.length) return; - if (!hasPendingSecondary()) return; + // Note: we deliberately don't short-circuit when the current bootstraps + // list lacks any secondary entry. The desktop pool only publishes a + // backend's bootstrap once its first start cycle has produced a config + // (see desktop.ipc.window.getLocalEnvironmentBootstraps), so an in-flight + // WSL cold boot looks identical to "no WSL configured" from this side. + // We have to keep polling until either a secondary actually shows up or + // the budget runs out. const delay = AUTO_RETRY_DELAYS_MS[autoRetryAttempt]; autoRetryAttempt += 1; autoRetryHandle = setTimeout(() => {