Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSIS with oneClick set to true does not relaunch the app after update #884

Closed
SxMShaDoW opened this issue Nov 5, 2016 · 13 comments · May be fixed by qcif/data-curator#563
Closed

NSIS with oneClick set to true does not relaunch the app after update #884

SxMShaDoW opened this issue Nov 5, 2016 · 13 comments · May be fixed by qcif/data-curator#563

Comments

@SxMShaDoW
Copy link

SxMShaDoW commented Nov 5, 2016

  • Version: 7.21.0
  • Target: Windows NSIS

Description of the problem: Windows NSIS with oneClick set to true does not relaunch the app after update (using quitAndInstall). On the other hand, using the same build for OSX (Squirrel.Mac) it relaunches the app after updating (using the same code of quitAndInstall). This confuses the customer as there is no installergif or validation that the update is done.

Configuration looks like:

"build": {
    "appId": X
    "asar": false,
    "category": X
    "win": {
      "target": "nsis"
     },
     "nsis": {
      "guid": X,
      "oneClick": true
    }
@develar
Copy link
Member

develar commented Nov 5, 2016

macOS also doesn't relaunch app — update silently installed on quit. Are you sure?

@SxMShaDoW
Copy link
Author

It does for me. Is it not supposed to relaunch the app after the update? I will post some of our updating code then.

@SxMShaDoW
Copy link
Author

SxMShaDoW commented Nov 5, 2016

I don't think we are doing anything special below.

We have IPC handlers that are promises and check for updates on init. If an update is found: A modal pops up, silently downloads, then quits, removes old, installs new app, then boots it back up on Mac. Using electron-release-server for squirrel.Mac and an S3 bucket as the generic provider for windows.

import { autoUpdater } from 'electron-auto-updater'; 
import ....;
/**
 * Initializes the autoUpdater event functions and feedURL
 */
export function updateInit() {
  autoUpdater.on('update-available', function(event) {
    logger.log(`Update available ${JSON.stringify(event)}`);
  });

  autoUpdater.on('update-downloaded', function(event, releaseNotes, releaseName, releaseDate, updateURL) {
    logger.log(`Update downloaded ${JSON.stringify(event)}`);
    autoUpdater.quitAndInstall();
  });

  autoUpdater.on('error', function(error, msg) {
    logger.error(`Update error ${JSON.stringify(error)}`);
    logger.error(`Update error ${JSON.stringify(msg)}`);
  });

  autoUpdater.on('checking-for-update', function(event) {
    logger.log(`Checking-for-update ${JSON.stringify(event)}`);
  });

  autoUpdater.on('update-not-available', function(event) {
    logger.log(`Update not available ${JSON.stringify(event)}`);
  });
  if (os === 'darwin') {
    let feedurl = `${releaseServer}/update/${os}/${appVersion}`;
    autoUpdater.setFeedURL(feedurl);
  }
}


/**
 * Uses the autoUpdater to checkForUpdates. Has a timeout of ten seconds
 * @return {Boolean}        whether or not there is an update available
 */
export const checkForUpdate = () => {
  return new Promise(async (resolve, reject) => {
    try {
      if (os === 'darwin') {
        autoUpdater.setFeedURL(`${releaseServer}/update/${os}/${appVersion}`);
      }
      autoUpdater.checkForUpdates();
      // Safety check the event and resolve true if an update is available
      autoUpdater.on('update-available', function(event) {
        logger.log(`Update available ${JSON.stringify(event)}`);
        return resolve(true);
      });
      // Safety check the event and resolve false if an update is not available
      autoUpdater.on('update-not-available', function(event) {
        logger.log(`Update not available ${JSON.stringify(event)}`);
        return resolve(false);
      });
      // Set a timeout for finding the update in case the server does not respond
      setTimeout(() => {
        return resolve(false);
      }, autoUpdateTimeoutMs);
    } catch (err) {
      logger.log(`Could not get update. ${err}`);
      return resolve(false);
    }
  });
};

@develar
Copy link
Member

develar commented Nov 5, 2016

In general, I don't recommend to call autoUpdater.quitAndInstall explicitly.

Please see https://github.com/develar/onshape-desktop-shell/blob/nsis/src/AppUpdater.ts

Why do you need to bother user? Just show notification (native) that "Version ${releaseName} is downloaded and will be automatically installed on Quit" and nothing else. Don't interrupt user work. Exactly as Google Chrome update works (even without notification, only toolbar icon has different colour).

Ok, ok, up to you. If you say that explicit quitAndInstall on macOs does relaunch — I will check and fix NSIS updater.

@SxMShaDoW
Copy link
Author

If you are unable to reproduce it and/or its too heavy to fix, I will look into the Google Chrome way and potentially remind people to quit the app so they can get the latest versions.

There are pros and cons to both, as you may know.

For example a pro of "interrupting" way would be:
People will always get the latest updates. It takes less than 3 minutes on mac and less than 5 minutes on windows.

An example of a con would be:
If people never close the application, they will never get the latest releases that have critical features or bug fixes. I've seen this in many situations (esp Google Chrome). People like to keep all their tabs open and multiple windows, therefore they never get the latest.

In our case, the application is more of a platform, and its okay to interrupt the customer because no data is lost or needed to be saved via our application.

All in all, I appreciate the guidance. Thanks!

@develar
Copy link
Member

develar commented Nov 5, 2016

You are right, thanks.

But in this case (explicit quitAndInstall), install of update should be not silent, right? Some progress should be reported — i.e. the same as in case of standard install.

@SxMShaDoW
Copy link
Author

SxMShaDoW commented Nov 5, 2016

I wasn't going to be picky, but the install update showing progress would be great! An installer gif or a progress bar (similar to a normal install) would be awesome.

@Jflinchum
Copy link

Also, not sure if you know about this, but if you have the app on your taskbar on Windows and the app updates, the shortcut gets removed. It works fine on Mac, but I suspect that the NSIS updater deletes the shortcut when uninstalling the old app.

@pwdl
Copy link

pwdl commented Nov 17, 2016

I have a similar need for an application that I am developing - where the application is open/active for a very long time and the user is not going to close and restart the application.
I've coded for an update check and then prompting the user that the update is available.

However, I am encountering the same issue whereby the autoUpdater.quitAndInstall() call does quit and update the application, however, it does not restart the application.

As an aside - I am also considering adding an update check silently and then presenting the user with a prompt that the application will be upgraded in X minutes with the option to 'dismiss' this instance of the update.

Naturally, I will need the auto-restart issue to work before I do this. Any ideas as to what may be causing this issue?

I found a similar issue raised several years ago by the looks of things. Not sure if it is relevant...

@develar
Copy link
Member

develar commented Nov 19, 2016

Fixed in electron-auto-updater 0.6.0.

Please note — currently, app will be relaunched only if you don't set runAfterFinish to false (defaults to true, if you didn't customise it, don't worry).

@develar
Copy link
Member

develar commented Nov 19, 2016

@pwdl I hope your issue is fixed as well.

@SxMShaDoW
Copy link
Author

@develar - do you know if this will fix @Jflinchum issue as well, or should that be a different issue? I notice similar behavior.

When you do auto-update, it installs it in a new folder, deletes the old folder, and leaves the dock icon referencing a folder that doesn't exist.

Example workflow:

### User side: 
1. user has electron app on Windows Dock.
2. User runs electron app on 2.0.21. It is installed in C:\Program Files\electron-app\2.0.21\electron-app.exe 
3. User boots up the app. 
4. User gets install prompt. Accepts it.
5. The app downloads. 
### Electron-App: 
* Creates a new folder 2.0.22. 
* Installs Electron-app in the  2.0.22. 
* Deletes folder 2.0.21.
* leaves the dock icon referencing a folder and .exe that doesn't exist.

@develar
Copy link
Member

develar commented Nov 19, 2016

@SxMShaDoW please file your comment as new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants