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.
This commit is contained in:
Josh Gratton committed 2026-05-18 12:37:42 -04:00
1 parent c3374a85ca
commit ba31706c20
1 file changed
+13 -2
+13 -2
View File
@@ -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,