From ba31706c201aeada76037d474bced76d4615226e Mon Sep 17 00:00:00 2001 From: Josh Gratton Date: Mon, 18 May 2026 12:37:42 -0400 Subject: [PATCH] fix(desktop): stop every pool instance before update install, not just primary quitAndInstall fires app.quit() + a hard relaunch, which may not wait for Effect's scope finalizer cascade to drain. With parallel backends that meant the WSL instance got hard-killed by the OS instead of receiving the SIGTERM + grace period the BackendInstance stop finalizer provides. Iterate pool.list and stop every instance concurrently with the same 5s budget the primary had on its own. --- apps/desktop/src/updates/DesktopUpdates.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/updates/DesktopUpdates.ts b/apps/desktop/src/updates/DesktopUpdates.ts index 0b1e6ef915..23ce85ce3c 100644 --- a/apps/desktop/src/updates/DesktopUpdates.ts +++ b/apps/desktop/src/updates/DesktopUpdates.ts @@ -188,7 +188,6 @@ function isArm64HostRunningIntelBuild(runtimeInfo: DesktopRuntimeInfo): boolean const make = Effect.gen(function* () { const config = yield* DesktopConfig.DesktopConfig; const pool = yield* DesktopBackendPool.DesktopBackendPool; - const primaryBackend = yield* pool.primary; const desktopState = yield* DesktopState.DesktopState; const electronUpdater = yield* ElectronUpdater.ElectronUpdater; const electronWindow = yield* ElectronWindow.ElectronWindow; @@ -369,7 +368,19 @@ const make = Effect.gen(function* () { yield* Ref.set(updateInstallInFlightRef, true); return yield* Effect.gen(function* () { - yield* primaryBackend.stop({ timeout: Duration.seconds(5) }); + // Stop every backend in the pool, not just the primary. With + // parallel WSL + Windows backends, leaving the WSL instance up + // means quitAndInstall's app.quit() exits before the pool's + // scope cascade has a chance to run its stop finalizer, so the + // WSL child gets hard-killed by the OS instead of receiving + // SIGTERM + grace. Stops run concurrently with the same 5s + // budget the primary had on its own. + const instances = yield* pool.list; + yield* Effect.forEach( + instances, + (instance) => instance.stop({ timeout: Duration.seconds(5) }), + { concurrency: "unbounded" }, + ); yield* electronWindow.destroyAll; yield* electronUpdater.quitAndInstall({ isSilent: true,