Reputation: 309
electron builder version : 20.28.4
electron-updater version : 3.1.2
building for OSx, Windows & Ubuntu
I'm trying to create an electron app with an auto update mechanism. I'm facing an issue with the auto updater, especially for OSx. It works quite good on linux and windows (new version is downloaded and installed with autoUpdater.quitAndInstall(); or when the user quit the app). On OSx however, the new version gets downloaded, but is never installed.
The event fired when on update is downloaded is this one so i'm sure that the update is actually downloaded :
autoUpdater.on('update-downloaded', (ev, info) => {
setImmediate(() => {
let iChoice = dialog.showMessageBox({
type: 'question',
message: oTrad['on-update-downloaded'],
buttons: [oTrad['quit_and_install'], oTrad['install_later']]
});
if (iChoice === 0) {
setImmediate(() => {
var browserWindows = BrowserWindow.getAllWindows();
browserWindows.forEach(function(browserWindow) {
browserWindow.destroy();
});
autoUpdater.quitAndInstall();
})
}
});
});
When the user click on "Quit and Install" which calls autoUpdater.quitAndInstall() the app does not actually close (still appear as open in the docks) and never actually re open itself. If I manually kill it and then launch it again -> the update-downloaded is fired again as if the update was never downloaded or installed in the first place. I'm quite lost since this mechanism is working perfectly on Linux & Windows.
UPDATE:
I found that my problem was related to the App Transport Security which was preventing the update on Mac, so I've added some configuration in my package.json to bypass that :
"extendInfo": {
"NSAppTransportSecurity": {
"NSAllowsArbitraryLoads": true
}
}
My problem now is that the quitAndInstall() function is not working. The new version is downloaded AND installed only when I actually closed the app. If I call quitAndInstall, I'll have the following bug :
Error: No update available, can't quit and install Proxy server for native Squirell.Mac is closed
Thanks in advance
Upvotes: 0
Views: 2829
Reputation: 223
I faced a similar issue for OSX and I solved it writing that. Before to quit I force to close all windows
if (iChoice === 0) {
setImmediate(() => {
app.removeAllListeners("window-all-closed")
autoUpdater.quitAndInstall(false)
})
}
Upvotes: 2
Reputation: 117
I had the same issue in MacOS and I managed to solve it. Below is the code which was not working.
autoUpdater.on("update-downloaded", updateInfo => { autoUpdater.quitAndInstall(); })
It closed the app but it never relaunched it. So I checked both log files of the electron app as well as the ShipIt and I realized that the moment the download is done, it would send a request to install the new application (even if you don't call the quitAndInstall method).
So to fix the issue, I just exited the app with a bit of a delay as it seems there is some sort of race issue here.
autoUpdater.on("update-downloaded", updateInfo => {
setTimeout(() => {
autoUpdater.quitAndInstall();
app.exit();
}, 10000);
})
I checked the logs in ShipIt at the same time and I saw that it began the installation process and right after it relaunched the app. So if you're on mac, try to exit (not quit) after the download is done. Mine works now.
Upvotes: 2