fix(updater): improve macOS update handling with forced app.quit() fallback (#196)

This commit is contained in:
Haze
2026-02-26 20:33:01 +08:00
committed by GitHub
Unverified
parent 0b2236f91f
commit aaa2864281

View File

@@ -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 { quitAndInstall(): void {
logger.info('[Updater] quitAndInstall called'); logger.info('[Updater] quitAndInstall called');
autoUpdater.quitAndInstall(); autoUpdater.quitAndInstall();
if (process.platform === 'darwin') {
setTimeout(() => {
logger.warn('[Updater] macOS: forcing app.quit() (Squirrel fallback)');
app.quit();
}, 3_000).unref();
}
} }
/** /**