GitbookIO / nuts

:chestnut: Releases/downloads server with auto-updater and GitHub as a backend
http://nuts.gitbook.com
Apache License 2.0
1.25k stars 300 forks source link

Error updating application #161

Open dguettler opened 6 years ago

dguettler commented 6 years ago

I'm running into the following error and am wondering if anybody has some hints how to debug this

[info] Checking for updates...
[error] There was a problem updating the application
[error] Error: Update check failed. The server sent an invalid response. Try again later.

From the Nuts logs I only see

download Oversight-osx-x64-0.0.12.zip for version 0.0.12 on channel stable for osx_64
downloaded Oversight-osx-x64-0.0.12.zip for version 0.0.12 on channel stable for osx_64

Testing the download URL via curl gets the correct zip file.

On the electron side I have

  const server = 'https://[REDACTED]'
  const feed = `${server}/download/${process.platform}`

  autoUpdater.setFeedURL(feed);

  setInterval(() => {
    log.info("Checking for updates...");
    autoUpdater.checkForUpdates();
  }, 60000);

  autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
    log.info("Update received: ", event, releaseNotes, releaseName);
    const dialogOpts = {
      type: 'info',
      buttons: ['Restart', 'Later'],
      title: 'Application Update',
      message: process.platform === 'win32' ? releaseNotes : releaseName,
      detail: 'A new version has been downloaded. Restart the application to apply the updates.'
    }

    dialog.showMessageBox(dialogOpts, (response) => {
      if (response === 0) autoUpdater.quitAndInstall()
    })
  })

  autoUpdater.on('error', (message) => {
    log.error('There was a problem updating the application')
    log.error(message)
  })

Any advice on next steps would be appreciated.

dguettler commented 6 years ago

Ok, my mistake. Everything started to work after changing the feedURL from download to update and include the version.

  const server = 'https://[REDACTED]'
  const version = app.getVersion();
  const feed = `${server}/update/${process.platform}/${version}`

The logs still indicate an error once the latest version has restarted. Seems like Squirrel.Mac doesn't like it if there is no update available.

[2018-04-19 17:03:44.073] [info] ===== Starting Oversight =====
[2018-04-19 17:03:44.073] [info] Version:  v7.9.0
[2018-04-19 17:04:43.918] [info] Checking for updates...
[2018-04-19 17:05:43.035] [info] Update received:  { preventDefault: [Function: preventDefault],
  sender: 
   AutoUpdater {
     _events: { 'update-downloaded': [Function], error: [Function] },
     _eventsCount: 2 } }  0.0.12
[2018-04-19 17:05:43.924] [info] Checking for updates...
[2018-04-19 17:06:08.197] [info] ===== Closing Oversight =====
[2018-04-19 17:06:24.629] [info] ===== Starting Oversight =====
[2018-04-19 17:06:24.633] [info] Version:  v7.9.0
[2018-04-19 17:07:24.448] [info] Checking for updates...
[2018-04-19 17:08:11.239] [error] There was a problem updating the application
[2018-04-19 17:08:11.240] [error] Error: Update check failed. The server sent an invalid response. Try again later.
fott1 commented 6 years ago

@dguettler Hey, did you used it over https without any issue?

dguettler commented 6 years ago

@fott1 indirectly yes. I have Nuts running in OpenShift, so the SSL termination happens at the edge and the request Nuts receives is http only.