From aaa28642817de8d9785599f042465f34047fa0ed Mon Sep 17 00:00:00 2001 From: Haze <709547807@qq.com> Date: Thu, 26 Feb 2026 20:33:01 +0800 Subject: [PATCH] fix(updater): improve macOS update handling with forced app.quit() fallback (#196) --- electron/main/updater.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/electron/main/updater.ts b/electron/main/updater.ts index 42a523018..92f8cda09 100644 --- a/electron/main/updater.ts +++ b/electron/main/updater.ts @@ -206,9 +206,25 @@ export class AppUpdater extends EventEmitter { } } + /** + * Install update and restart. + * + * On macOS, electron-updater's MacUpdater still delegates to Squirrel.Mac + * internally. Squirrel's quitAndInstall() is unreliable — it sometimes + * fails to trigger `before-quit`, leaving the tray close handler to + * intercept and hide the window instead of quitting. We force `app.quit()` + * after a short grace period as a safety net. + */ quitAndInstall(): void { logger.info('[Updater] quitAndInstall called'); autoUpdater.quitAndInstall(); + + if (process.platform === 'darwin') { + setTimeout(() => { + logger.warn('[Updater] macOS: forcing app.quit() (Squirrel fallback)'); + app.quit(); + }, 3_000).unref(); + } } /**