From 80eddbbef959b362a1784e684a648415bfd57226 Mon Sep 17 00:00:00 2001 From: Josh Gratton Date: Mon, 11 May 2026 10:38:16 -0400 Subject: [PATCH] fix(desktop): clear swap flow timer in finally + drop duplicate env-state removal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - move clearTimeout(flowTimeoutHandle) into the finally block so it fires on success, error, and timeout — previously the error path left a live 180s timer that would reject an unreferenced promise (unhandled rejection) - remove the second removeEnvironmentState call after welcome; the first call right after the IPC swap already wipes the old environment state and nothing recreates state under the old env id during reauth/welcome --- apps/web/src/components/settings/ConnectionsSettings.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx index d579e263d6..9e93b06797 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.tsx +++ b/apps/web/src/components/settings/ConnectionsSettings.tsx @@ -2433,16 +2433,10 @@ export function ConnectionsSettings() { window.setTimeout(resolve, 45_000); }), ]); - if (aborted) return; - - if (previousPrimaryEnvId) { - useStore.getState().removeEnvironmentState(previousPrimaryEnvId); - } }; try { await suppressReconnect(() => Promise.race([runSwap(), flowTimeout])); - if (flowTimeoutHandle !== null) window.clearTimeout(flowTimeoutHandle); setPendingDesktopWslSelection(null); toastManager.add({ @@ -2469,6 +2463,9 @@ export function ConnectionsSettings() { .then((state) => setDesktopWslState(state)) .catch(() => undefined); } finally { + // Clear the global timer on every path so it can't fire after the flow + // has settled and reject an unreferenced promise. + if (flowTimeoutHandle !== null) window.clearTimeout(flowTimeoutHandle); unsubscribeWelcome(); setIsUpdatingWslBackend(false); setDesktopWslChangeStage(null);