diff --git a/ElectronNET.Host/api/autoUpdater.js b/ElectronNET.Host/api/autoUpdater.js index 63e4c07..559c7aa 100644 --- a/ElectronNET.Host/api/autoUpdater.js +++ b/ElectronNET.Host/api/autoUpdater.js @@ -102,22 +102,25 @@ module.exports = (socket, app) => { }); socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => { app.removeAllListeners("window-all-closed"); - setImmediate(() => { - const windows = electron_1.BrowserWindow.getAllWindows(); - if (windows.length) { - windows.forEach(w => { - try { - w.removeAllListeners('close'); - w.hide(); - w.destroy(); - } - catch { - //ignore, probably already destroyed - } - }); - } + + const windows = electron_1.BrowserWindow.getAllWindows(); + if (windows.length) { + windows.forEach(w => { + try { + w.removeAllListeners('close'); + w.removeAllListeners('closed'); + w.destroy(); + } + catch { + //ignore, probably already destroyed + } + }); + } + //The call to quitAndInstall needs to happen after the windows + //get a chance to close and release resources, so it must be done on a timeout + setTimeout(() => { electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter); - }); + }, 100); }); socket.on('autoUpdaterDownloadUpdate', async (guid) => { const downloadedPath = await electron_updater_1.autoUpdater.downloadUpdate(); diff --git a/ElectronNET.Host/api/autoUpdater.ts b/ElectronNET.Host/api/autoUpdater.ts index 9451844..013adee 100644 --- a/ElectronNET.Host/api/autoUpdater.ts +++ b/ElectronNET.Host/api/autoUpdater.ts @@ -130,22 +130,25 @@ export = (socket: Socket, app: Electron.App) => { socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => { app.removeAllListeners("window-all-closed"); - setImmediate(() => { - const windows = BrowserWindow.getAllWindows(); - if (windows.length) { - windows.forEach(w => { - try { - w.removeAllListeners('close'); - w.hide(); - w.destroy(); - } - catch { - //ignore, probably already destroyed - } - }); - } + const windows = BrowserWindow.getAllWindows(); + if (windows.length) { + windows.forEach(w => { + try { + w.removeAllListeners('close'); + w.removeAllListeners('closed'); + w.destroy(); + } + catch { + //ignore, probably already destroyed + } + }); + } + + //The call to quitAndInstall needs to happen after the windows + //get a chance to close and release resources, so it must be done on a timeout + setTimeout(() => { autoUpdater.quitAndInstall(isSilent, isForceRunAfter); - }); + }, 100); }); socket.on('autoUpdaterDownloadUpdate', async (guid) => {