From a29a397e5546d13bcf028ebc155e1c500c9ebede Mon Sep 17 00:00:00 2001 From: Merge Sim Date: Thu, 3 Sep 2026 13:53:38 -0700 Subject: [PATCH] fix updater marker ordering and shutdown guard test --- src/main/updater/updater-install-execution.ts | 8 ++++---- src/renderer/src/lib/shutdown-checkpoint-guard.test.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/updater/updater-install-execution.ts b/src/main/updater/updater-install-execution.ts index 892ee22ea8e..da79c679144 100644 --- a/src/main/updater/updater-install-execution.ts +++ b/src/main/updater/updater-install-execution.ts @@ -100,16 +100,16 @@ export abstract class UpdaterInstallExecution extends UpdaterPackageRecovery { recordUpdaterLifecycle('quit_and_install_invoking_native', { version: pendingVersion || null }) + // Why: defensive — never call quitAndInstall if recovery/reset already cleared the handoff. + if (!this.quitAndInstallInProgress) { + return + } // Why before the native call: from here ShipIt waits for this process to exit, and any // launch of this bundle in that window cancels the install. The marker is the only way // a launching process can know that, because this process is about to be gone. if (process.platform === 'darwin') { markMacUpdateInstallInFlight(pendingVersion) } - // Why: defensive — never call quitAndInstall if recovery/reset already cleared the handoff. - if (!this.quitAndInstallInProgress) { - return - } // Why: mark before the call so a sync 'error' during quitAndInstall can recover; pre-native errors must not look like install failure. this.quitAndInstallNativeInvoked = true // Why: invoke before killAllPty/removing close listeners so a sync 'error' can recover while windows and PTYs are intact. diff --git a/src/renderer/src/lib/shutdown-checkpoint-guard.test.ts b/src/renderer/src/lib/shutdown-checkpoint-guard.test.ts index 469d1e25598..7c7693ba9d9 100644 --- a/src/renderer/src/lib/shutdown-checkpoint-guard.test.ts +++ b/src/renderer/src/lib/shutdown-checkpoint-guard.test.ts @@ -193,7 +193,7 @@ describe('createShutdownCheckpointGuard', () => { join(process.cwd(), 'src/renderer/src/components/use-terminal-editor-close-foundation.ts'), 'utf8' ) - const closeStart = source.indexOf('const confirmNativeWindowClose = useCallback(() => {') + const closeStart = source.indexOf('const confirmNativeWindowClose = useCallback(') const closeEnd = source.indexOf('window.api.ui.confirmWindowClose()', closeStart) expect(closeStart).toBeGreaterThanOrEqual(0) expect(closeEnd).toBeGreaterThan(closeStart)