electron-builder: Auto-Update quitAndInstall Not Working On Mac
“electron-builder”: “^18.2.1” “electron-updater”: “^1.16.0” Target: Mac
My auto-update on Windows is working fine. However I still have two issues on the Mac.
On the Mac it recognises that there is an update then asks the user if they want to download and install. If the user responds ‘Yes’ then the update is downloaded and the user is advised that the new version is downloaded and will be installed when they click OK. However the quitAndInstall never seems to get called. If I close the app and re-open it again it just goes through the same process. Also on Mac my progress is not logged to my log file, nor is the status bar working. Both of these things work correctly on Windows. See code and log file below.
`autoUpdater.on(‘download-progress’, (progressObj) => { let log_message = "Download speed: " + progressObj.bytesPerSecond; log_message = log_message + ’ - Downloaded ’ + progressObj.percent + ‘%’; log_message = log_message + ’ (’ + progressObj.transferred + “/” + progressObj.total + ‘)’; log.log(‘info’, log_message); mainWindow.setProgressBar((progressObj && progressObj.percent) ? progressObj.percent / 100 : -1) });
autoUpdater.on('update-downloaded', (versionInfo) => {
var dialogOptions = {
type: 'question',
defaultId: 0,
message: `The update is ready to install, Version ${versionInfo.version} has been downloaded and will be automatically installed when you click OK`
};
dialog.showMessageBox(mainWindow, dialogOptions, function() {
if (!isDev) {
autoUpdater.quitAndInstall();
}
});
});`
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (2 by maintainers)
Commits related to this issue
- fix: make quitAndInstall work on macos gotta clear all listeners on all the windows for quitAndInstall to work. Now auto-update works as expected on mac. thanks to the proposed fix on this issue: ht... — committed to ipfs/ipfs-desktop by olizilla 5 years ago
- fix: app updater quit and install not working https://github.com/electron-userland/electron-builder/issues/1604 — committed to krud-dev/ostara by avivm a year ago
- fix: app updater quit and install not working (#659) * fix: app updater quit and install not working https://github.com/electron-userland/electron-builder/issues/1604 * docs(changeset): Fixed ... — committed to krud-dev/ostara by avivm a year ago
It is not electron-updater issue. Please see https://github.com/electron/electron/issues/3583
As you have made a donation, issue was investigated by me for you.
You need to modify your code:
quitAndInstallor other actions only in thesetImmediate. To ensure that all dialog/sheet windows were released.window-all-closedhandler (if it is added, e.g. https://github.com/develar/onshape-desktop-shell/blob/master/src/WindowManager.ts#L16) doesn’t prevent quit, remove all such listenersapp.removeAllListeners("window-all-closed").mainWindow.close()If you have more than one windows, close all (BrowserWindow.getAllWindows()to get all windows).If still no luck — try
mainWindow.destroy().Don’t forget to update to electron-updater 2.1.1
I (quite naturally) had a
closeevent on a BrowserWindow set up (for Macs) in order to capture theCommand+Whotkey. Because of this, theautoUpdater.quitAndInstallmethod wasn’t working. Here’s my go at a helper-function to deal with cases of aggressive event listeners preventing the app from properly restarting:Hope this is helpful to someone out there 😃
@sweetevil unfortunately, the author left out a critical piece of information from the documentation – auto updating will not work unless your Mac application is signed.
I found this out by reading through the electron docs for auto updating.
As electron-builder makes use of Squirrel.Mac, this may be the cause of your issue.
@Kirezi
Sadly, it’s been years, and I ended up abandoning our attempt at a native (Electron wrapped) app. At the time, Electron required way (way way) too much low-level logic to work reliably. It’s been years, so my guess is it’s not as bad anymore. But I’m not sure where exactly I put that. Likely in the boot script (or whatever the language equivalent of that is these days).
This (we think) just solved a massive issue with our app’s upgrade flow. Thanks!