Reputation: 1538
I have an electron app which uses electron-builder
for building, packing & publishing the app.
I have the following auto-update code:
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = "info";
autoUpdater.autoDownload = true;
const updateCheck = () => {
autoUpdater.checkForUpdates().then(resp => {
log.info("autoUpdate response:");
log.info(resp);
});
};
app.on("ready", async () => {
log.info(`Version: ${app.getVersion()}`);
autoUpdater.on("update-downloaded", () => {
log.info("update downloaded");
setImmediate(() => {
try {
log.info("installing update");
// app.relaunch();
autoUpdater.quitAndInstall();
} catch (err) {
log.error("Error installing update");
log.error(err);
}
});
});
autoUpdater.on("error", err => {
log.error("AutoUpdater error");
log.error(err);
});
updateCheck();
schedule.scheduleJob("*/10 * * * *", updateCheck);
});
When I publish a new version, the auto-updater detects it, downloads it successfully, and then tries to install it.
During installation of the update, the progress bar fills up halfway, then disappears.
The app remains closed and does not automatically relaunch after the progress bar disappears.
When I re-launch it manually, it is still the old version. It detects that there is an update which has already downloaded, and tries to install it, with the same result (progress bar fills halfway then disappears, app remains closed after).
My log file shows no errors, either from the catch block or the autoUpdater.on("error")
callback.
The location C:\Users\<User>\AppData\Local\<app-name>-updater
has an installer.exe
file which installs the previous version, and a pending
folder which contains an installer for the new version. Manually executing this installer causes the app to be updated with no errors.
I tried testing using checkForUpdatesAndNotify
instead of checkForUpdates
(and commenting out the call to quitAndInstall
), and it worked as advertised, however I would like to ensure the update is installed immediately rather than wait for the user to quit on their own.
How can I debug this further? Why am I not seeing any errors? Where should I be looking for them? What am I doing wrong?
Upvotes: 5
Views: 4187
Reputation: 11
I had the same problem on windows. It quits suddenly every time the update is halfway through. After searching for a long time, I finally found that it has something to do with the name of the damn installation package. Remember that the artifactName must be followed by the version number, for example: artifactName: '${productName}-${version}.${ext}'
, otherwise this problem will occur. mine is normal
Upvotes: 1
Reputation: 87
I was facing the same issue and I did a lot of RnD. After trying for few days I found that there was no issue with the auto updater instead it was the issue with the file name I was uploading on my server. Make sure your exe file name for every new version is different otherwise it will not install after auto update. For eg. setup_0.0.1.exe than your next version file should be setup_0.0.2.exe Make sure to update the file name in latest.yml and blockmap file as well.
Upvotes: 0
Reputation: 364
Quick question: have you used this answer to make your App window closed and minimizable to tray?
If you did, You should application.isQuiting = true
before calling autoUpdater.quitAndInstall();
otherwise the application.close()
function is pretty much blocked from anywhere other then the contextMenu
.
Upvotes: 1
Reputation: 1538
The problem turned out to be the fact that I created the window with the option closable: false
, preventing the auto updater from closing it. The auto updater works perfectly after removing this setting
Upvotes: 2