Skip to content

The agent that grows with you

fix(desktop): raise backend readiness deadline 45s to 180s

Austin Pickett895ef9b839a3
diff --git a/apps/desktop/electron/backend-health.ts b/apps/desktop/electron/backend-health.ts
index 6513b1e6974..43eda7c3a95 100644
--- a/apps/desktop/electron/backend-health.ts
+++ b/apps/desktop/electron/backend-health.ts
@@ -1,4 +1,10 @@
-export const DEFAULT_BACKEND_READY_TIMEOUT_MS = 45_000
+// A cold backend boot (plugin discovery + route mounting at web_server import
+// time) can take 45-60s on slower hardware. A 45s deadline makes first-boot
+// readiness a coin flip: every lost race tears down a healthy-but-slow backend
+// and re-drives boot, which cascades into minutes of "not connected" and
+// orphaned python processes (#63454). The poll returns the moment the backend
+// responds, so fast machines see no change; 180s is deliberately generous.
+export const DEFAULT_BACKEND_READY_TIMEOUT_MS = 180_000
export const DEFAULT_BACKEND_READY_POLL_MS = 500
// A cold backend can stall its event loop for tens of seconds while Windows
// scans and byte-compiles the gateway import tree. At the default 15s socket
diff --git a/apps/desktop/src/lib/with-timeout.ts b/apps/desktop/src/lib/with-timeout.ts
index 3bcbf94ac41..9197aaa8fed 100644
--- a/apps/desktop/src/lib/with-timeout.ts
+++ b/apps/desktop/src/lib/with-timeout.ts
@@ -6,7 +6,11 @@
* backend is not coming and the caller should fail instead of hanging.
* Reconnect-class awaits against an already-spawned backend use the shorter
* RECONNECT_ATTEMPT_TIMEOUT_MS below instead. */
-export const BACKEND_BOOT_WAIT_TIMEOUT_MS = 45_000
+// Keep in lockstep with DEFAULT_BACKEND_READY_TIMEOUT_MS in
+// electron/backend-health.ts: the renderer must out-wait the main process
+// cold-boot budget, or it flips to "not connected" and re-drives boot while
+// main is still mid-wait (#63454).
+export const BACKEND_BOOT_WAIT_TIMEOUT_MS = 180_000
// desktop.getConnection() / getConnectionFor() / revalidateConnection() /
// resolveGatewayWsUrl() are IPC round-trips into the main process with no