5

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?

1
  • 1
    Following as I have the exact same problem. Before the install bar disappears, a console window opens and closes immediately, so I guess if there is any useful indication there. Will update if I find out something Commented Oct 30, 2019 at 18:02

4 Answers 4

2

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

1
  • how did you show a progress bar while installing? I thought all windows are closed while installing so there's no way to have a progress bar showing, i dont se the updater to provide an event to update any progress bar either (only the download progress but not the actual installation progress) Commented Jun 1, 2022 at 22:41
1

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.

1
  • no, I use window.hide() to minimize it to the tray and window.show() to re-open it when necessary
    – Katie
    Commented Jan 16, 2020 at 3:10
1

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

0
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.