From c8552041fb38632bd8619e2ee3233a00c7775b29 Mon Sep 17 00:00:00 2001 From: rafael-aero Date: Thu, 10 Feb 2022 00:00:51 +0100 Subject: [PATCH] Add debug messages for update methods --- ElectronNET.Host/api/autoUpdater.js | 8 +++++++- ElectronNET.Host/api/autoUpdater.ts | 7 ++++++- ElectronNET.Host/main.js | 7 +++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ElectronNET.Host/api/autoUpdater.js b/ElectronNET.Host/api/autoUpdater.js index 2bdea23..683c1d4 100644 --- a/ElectronNET.Host/api/autoUpdater.js +++ b/ElectronNET.Host/api/autoUpdater.js @@ -101,9 +101,12 @@ module.exports = (socket, app) => { }); }); socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => { + console.log('running autoUpdaterQuitAndInstall'); + app.removeAllListeners("window-all-closed"); + const windows = electron_1.BrowserWindow.getAllWindows(); - if (windows.length) { + if (windows && windows.length) { windows.forEach(w => { try { w.removeAllListeners('close'); @@ -118,6 +121,9 @@ module.exports = (socket, app) => { //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(() => { + console.log('running autoUpdater.quitAndInstall'); + console.log('isSilent:' + isSilent); + console.log('isForceRunAfter:' + isForceRunAfter); electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter); }, 100); }); diff --git a/ElectronNET.Host/api/autoUpdater.ts b/ElectronNET.Host/api/autoUpdater.ts index b1e74f5..34715a2 100644 --- a/ElectronNET.Host/api/autoUpdater.ts +++ b/ElectronNET.Host/api/autoUpdater.ts @@ -130,9 +130,11 @@ export = (socket: Socket, app: Electron.App) => { }); socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => { + console.log('running autoUpdaterQuitAndInstall'); + app.removeAllListeners("window-all-closed"); const windows = BrowserWindow.getAllWindows(); - if (windows.length) { + if (windows && windows.length) { windows.forEach(w => { try { w.removeAllListeners('close'); @@ -147,6 +149,9 @@ export = (socket: Socket, app: Electron.App) => { //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(() => { + console.log('running autoUpdater.quitAndInstall'); + console.log('isSilent:' + isSilent); + console.log('isForceRunAfter:' + isForceRunAfter); autoUpdater.quitAndInstall(isSilent, isForceRunAfter); }, 100); }); diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index 99f6809..536aeef 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -55,6 +55,8 @@ app.on('will-finish-launching', () => { }); function prepareForUpdate() { + console.log('closing all windows before update'); + ignoreApiProcessClosed = true; app.removeAllListeners("window-all-closed"); @@ -487,14 +489,19 @@ function startAspCoreBackendWithWatch(electronPort) { if (code != 0) { console.log(`Will quit Electron, as exit code != 0 (got ${code})`); } + console.log('Will quit Electron now'); app.exit(code); } else if (os.platform() === 'darwin') { + console.log('.NET process and Electron has a pending update, will force quit in 10s...'); //There is a bug on the updater on macOS never quiting and starting the update process //We give Squirrel.Mac enough time to access the update file, and then just force-exit here setTimeout(() => app.exit(0), 10_000); } + else { + console.log('.NET process and Electron has a pending update...'); + } }); if (detachedProcess) {