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-web and nsis, public GitHub: Electron-updater don't start downloading after update-available #2377

Closed
marceloavf opened this issue Dec 11, 2017 · 39 comments

Comments

@marceloavf
Copy link
Contributor

After autoUpdater.checkForUpdates(), it emmits update-available but don't start downloading.
I'm using GitHub to publish.


  • Electron-updater - Version: 2.17.3
  • Electron-builder - Version: 19.48.3
  • Target: Windows | nsis-web
@develar
Copy link
Member

develar commented Dec 12, 2017

Do you use private GitHub?

@marceloavf
Copy link
Contributor Author

No, it's public GitHub

@develar
Copy link
Member

develar commented Dec 12, 2017

2.17.4 works for me, please verify.

@marceloavf
Copy link
Contributor Author

Still not working with 2.17.4

image

@develar
Copy link
Member

develar commented Dec 12, 2017

Is your old version of app (update from) uses electron-updater 2.17.4?

@marceloavf
Copy link
Contributor Author

Yes, I generate two version with 2.17.4 with some small changes, try to update from my app v1.17.2 that uses the 2.17.4 to 1.17.3 that also use it

@aenario
Copy link

aenario commented Dec 13, 2017

Hello @develar I just debugged a similar issue and it seem to be related to redirection.

May be it's only for big bundles, but github is redirecting to amazonS3, which is not followed by electron's net package because of the the redirect: "manual".

I am not sure why you need to manually deal with redirection in this package, and I am confused by the structure between Provider <-> Executor <-> Updater and so on, so I won't be pushing a PR. However, I got it fixed with this hacky monkey patch :

const _mp = autoUpdater.httpExecutor.doRequest
    autoUpdater.httpExecutor.doRequest = function (options, callback) {
        const req = _mp.call(this, options, callback)
        req.on('redirect', () => req.followRedirect())
        return req
    }

Hope that helps to pinpoint the issue and solve it more definitively.

@long-woo
Copy link

After upgrading to 2.17.4, download-progress can be called under Mac OS, but it can't be called under Windows

@develar
Copy link
Member

develar commented Dec 13, 2017

@aenario If you use private GitHub provider, it is fixed in the electron-updater 2.17.5

@develar
Copy link
Member

develar commented Dec 13, 2017

Please in any comment about electron-updater issue provide: 1. provider (GitHub or s3 or ...) 2. target (nsis-web or nsis or appimage)

@develar develar changed the title Electron-updater don't start downloading after update-available nsis-web: Electron-updater don't start downloading after update-available Dec 13, 2017
@develar
Copy link
Member

develar commented Dec 13, 2017

electron-updater 2.17.6 released.

If error still here, please enable debug logging to file and provide logs. Debug logging is cheap and doesn't lead to performance degradation, so, you can enable it and disable once you will verify that updater work.

const log = require("electron-log")
log.transports.file.level = "debug"
autoUpdater.logger = log

@marceloavf
Copy link
Contributor Author

marceloavf commented Dec 13, 2017

2.17.6 not working here, log:
Wait for 10 minutes and check network resources but no download started.

[2017-12-13 08:07:20.136] [info] Checking for update...
[2017-12-13 08:07:26.378] [info] Found version 1.17.8 (url: inovafarma-notificacoes-1.17.8-win.exe)
[2017-12-13 08:07:26.378] [info] Update available.
[2017-12-13 08:07:26.378] [info] { version: '1.17.8',
  files: 
   [ { url: 'inovafarma-notificacoes-1.17.8-win.exe',
       sha512: 'DkjNsoibQyGv+kgFEHxNqDBp2AhYP8+Eo0U94ULfBWpJrQG6Tmvtt0Rc1rmbgeiL2yqUTR39jxsaswo8S7J4Iw==' } ],
  path: 'inovafarma-notificacoes-1.17.8-win.exe',
  sha512: 'DkjNsoibQyGv+kgFEHxNqDBp2AhYP8+Eo0U94ULfBWpJrQG6Tmvtt0Rc1rmbgeiL2yqUTR39jxsaswo8S7J4Iw==',
  packages: 
   { ia32: 
      { path: 'inovafarma-notificacoes-1.17.8-ia32.nsis.7z',
        size: 36392513,
        blockMapSize: 72504,
        sha512: 'hxcOmeN65Duza8SlOUngCZKwoVqnKJRM7njsIAcqK4TJJsQQdeKzvOO9vM7e1lj1VgJKppjjzAvMCWba/CJ/fA==',
        headerSize: 10006 },
     x64: 
      { path: 'inovafarma-notificacoes-1.17.8-x64.nsis.7z',
        size: 42347040,
        blockMapSize: 82951,
        sha512: 'YQnQ7Y6zRb0I4LCh+i3IEMZzyxt4GLfW/4zyl6vcqGd8vN4yuvip8xpg4b90Tx3GCbqI7aAxwqXnnrpbdpLIFg==',
        headerSize: 10006 } },
  sha2: 'f0add7ee083188167b675ddc520dbe6ffb99526b7b6a06a57deb95962c891726',
  releaseDate: '2017-12-12T15:51:34.558Z',
  releaseName: '1.18.0',
  releaseNotes: '' }
[2017-12-13 08:07:26.380] [info] Downloading update from inovafarma-notificacoes-1.17.8-win.exe

autoUpdater code:

autoUpdater.allowDowngrade = true;

autoUpdater.on('checking-for-update', () => {
  log('Checking for update...');
  ipc.sender('check-for-updates', {
    message: 'Verificando atualizações...',
    emitter: 'checking-for-update',
    response: true,
  });
});

autoUpdater.on('update-available', (info) => {
  log('Update available.');
  log(info);
  ipc.sender('check-for-updates', {
    message: 'Atualizações disponíveis...',
    emitter: 'update-available',
    response: true,
  });
});

autoUpdater.on('update-not-available', (info) => {
  log('No update available. More info:');
  log(info);
  ipc.sender('check-for-updates', {
    message: 'Última versão instalada...',
    emitter: 'update-not-available',
    response: false,
  });
});

autoUpdater.on('error', (err) => {
  log.error(`Error in auto-update. ${err}`);
  ipc.sender('check-for-updates', {
    message: 'Problemas de conexão com o servidor...',
    emitter: 'error',
    response: false,
  });
});

let setIntervalStop = false;
autoUpdater.on('download-progress', (progressObj) => {
  let logMessage = `Download speed: ${helpers.bytesToSize(progressObj.bytesPerSecond)}/s`;
  logMessage = `${logMessage} - Downloaded ${progressObj.percent.toFixed()}%`;
  logMessage = `${logMessage} (${helpers.bytesToSize(progressObj.transferred)}/${helpers.bytesToSize(progressObj.total)})`;
  log(logMessage);
  ipc.sender('check-for-updates', {
    message: 'Baixando atualizações',
    percentage: `${progressObj.percent.toFixed()}%`,
    emitter: 'download-progress',
    response: true,
  });
});

autoUpdater.on('update-downloaded', () => {
  setIntervalStop = true;
  log('Update downloaded');
  ipc.sender('check-for-updates', {
    message: 'Instalando atualizações...',
    emitter: 'update-downloaded',
    response: true,
  });
});

ipcMain.on('quit-and-install', () => {
  log('Quit and install update');
  if (process.env.NODE_ENV === 'production' && process.env.BABEL_ENV !== 'test') {
    autoUpdater.quitAndInstall(true, true);
  }
});

ipcMain.on('check-for-updates', () => {
  setImmediate(() => {
    autoUpdater.allowPrerelease = allowPrerelease;
    log(`Allow Prerelease: ${allowPrerelease}`);
    autoUpdater.checkForUpdates();
  });
});

@develar
Copy link
Member

develar commented Dec 13, 2017

@marceloavf Is debug enabled?

@marceloavf
Copy link
Contributor Author

marceloavf commented Dec 13, 2017

@develar I used your code above

image

I'll try to clean all log configuration and re-do the test

@develar develar reopened this Dec 13, 2017
@develar
Copy link
Member

develar commented Dec 13, 2017

#2379 merged into this issue.

@develar develar changed the title nsis-web: Electron-updater don't start downloading after update-available nsis-web and nsis: Electron-updater don't start downloading after update-available Dec 13, 2017
@develar develar changed the title nsis-web and nsis: Electron-updater don't start downloading after update-available nsis-web and nsis, public GitHub: Electron-updater don't start downloading after update-available Dec 13, 2017
@sebn
Copy link

sebn commented Dec 14, 2017

Same issue here:

  • electron 1.7.9
  • electron-builder 19.49.0
  • electron-updater 2.17.6
  • provider: github (public)
  • target: nsis / dmg+zip / appimage

Auto-update works everywhere except on Windows.

Monkey patch from @aenario just works.

@Zamiell
Copy link

Zamiell commented Dec 16, 2017

Yup, this bug is easily reproducable. I have set up a test repository that showcases the issue here:
https://github.com/Zamiell/test

This repo is just the electron-quick-start repo with some small changes:

  • showing the dev tools on start
  • showing the app version below the other versions
  • adding the auto update code that is told in the official electron builder documentation
  • added the debug logging that is told in the official electron builder documentation

Some notes:

  • uses electron 1.8.1
  • uses the latest versions of electron-builder and electron-updater
  • it happens on BOTH nsis and nsis-web
  • build target is windows, testing happens in Windows 7

Here is the log file:

[2017-12-16 12:18:08.014] [info] Checking for update
[2017-12-16 12:18:10.857] [info] Found version 0.0.9 (url: electron-quick-start-setup-0.0.9.exe)
[2017-12-16 12:18:10.857] [info] Downloading update from electron-quick-start-setup-0.0.9.exe

And then it just hangs there and doesn't download update. So this is a severe regression!

@Zamiell
Copy link

Zamiell commented Dec 16, 2017

Also, monkey patch from above works for me to fix this problem. I put it right before the line of:

autoUpdater.checkForUpdatesAndNotify()

Also, as a side note, @develar can you update the documentation? I think it should explain the difference between checkForUpdates and checkForUpdatesAndNotify. This is very confusing for the end user:

image

@sheldhur
Copy link

  • electron 1.6.12
  • electron-builder latest
  • electron-updater 2.17.0-2.17.6
  • provider: github (public)
  • target: nsis

The same problem for 2.17.0-2.17.6 versions. But in 2.16.3 all is work :)

@metal-messiah
Copy link

metal-messiah commented Dec 22, 2017

can confirm same problem with 2.17.6

i switched down to 2.16.3 like @sheldhur suggested, and it does now download the file.
new dependencies are
electron - 1.7.9
electron-builder - 19.49.0
electron-updater - 2.16.3
provider - github (public)
target - nsis

when i apply the updates though, (tried both quitAndInstall() -- and just manually closing the app) i get the attached error, even though the file exists in the designated path, and the log appears to show no problems.

image

image

i'm so close to getting this thing working, any help or advice would be greatly appreciated!

@gordonshieh
Copy link

gordonshieh commented Dec 22, 2017

I did some sleuthing, and found that in BaseUpdater.js:87 of electron-builder
const destinationFile = _path.join(tempDir, _path.posix.basename(fileInfo.url.pathname));
should be:
const destinationFile = _path.join(tempDir, _path.posix.basename(fileInfo.info.url));

That will download the installer with the proper filename. I just found the fix, so I can't exactly have a clean slate that is reproducible for submitting a new PR.

Electron 1.7.9
Electron-builder 19.49.0

@metal-messiah
Copy link

can confirm that the changes @gordonshieh94 suggested worked. updated BaseUpdater.js and file is now updating as intended. thanks!

@develar
Copy link
Member

develar commented Dec 23, 2017

@gordonshieh94 It looks strange. But — as we do basename in any case, resolved URL is not required in our case and probably it is better to avoid complex code like url.pathname (where url it is instance of node URL) and use simple string url as in the update info. I will release new version with this fix. Thanks a lot.

@develar
Copy link
Member

develar commented Dec 23, 2017

Please try electron-updater 2.17.7

@marceloromaomultilaser
Copy link

marceloromaomultilaser commented Dec 23, 2017

Still not working for me =(

electron - 1.7.5
electron-builder - 19.49.3
electron-updater - 2.17.7
provider - github (private)
target - nsis

capturar

@gordonshieh
Copy link

The monkey patch posted above is still required. develar's commit does seem to address the ENOENT issue that metal-messiah and I are having though.

@sheldhur
Copy link

sheldhur commented Dec 25, 2017

Not working

  • electron - 1.6.12
  • electron-builder - 19.49.2
  • electron-updater - 2.17.7
  • provider - github (public)
  • target - nsis

@FantasticFiasco
Copy link

Any progress on this issue?

FantasticFiasco added a commit to FantasticFiasco/searchlight that referenced this issue Dec 28, 2017
The package upgrade is rejected due to a bug in electron-updater. For more information see electron-userland/electron-builder#2377.
@sheldhur
Copy link

sheldhur commented Jan 3, 2018

2.18.2 works for me

  • electron - 1.7.10
  • electron-builder - 19.51.0
  • electron-updater - 2.18.2
  • provider - github (public)
  • target - nsis

@FantasticFiasco
Copy link

Works for me to

@develar
Copy link
Member

develar commented Jan 8, 2018

Thanks for confirmation.

@develar develar closed this as completed Jan 8, 2018
@damianobarbati
Copy link

@marceloavf did you solve this? I see a partial download (about 5mb) and my app just quits without emitting upload-downloaded event.

I'm having no help here: #2977 :\

@marceloavf
Copy link
Contributor Author

@damianobarbati It's working since 2.18.2 here, one project in GitHub and another in Digital Ocean Spaces, also tested here on Windows 10, I'll take a look and give you any feedback if I find something.

@damianobarbati
Copy link

Thanks @marceloavf, I'm on:

"electron": "^2.0.1",
"electron-builder": "^20.13.4",
"electron-updater": "^2.21.10",

Should I downgrade?

@marceloavf
Copy link
Contributor Author

marceloavf commented Jun 6, 2018

My latest project is working on this versions @damianobarbati, using Digital Ocean Spaces:

electron@^1.8.4:
  version "1.8.4"

electron-builder@^20.8.1:
  version "20.8.1"

electron-updater@^2.21.4:
  version "2.21.4"

Try them to see if something changes, you can also try to delay your autoUpdate functions too.

@damianobarbati
Copy link

@marceloavf what do you mean with "Try them to see if something changes, you can also try to delay your autoUpdate functions too."?

@marceloavf
Copy link
Contributor Author

marceloavf commented Jul 20, 2018

You can use SetTimeout or setImmediate to delay your update function, waiting for your electron app fully loads before trying to check for update @damianobarbati .

@damianobarbati
Copy link

@marceloavf are you arguing that the app.on('ready', () => {}) event may be not reliable?

@marceloavf
Copy link
Contributor Author

It is reliable @damianobarbati, the point is that if you load your browserWindow, tray, etc you can have some undesired effects like app hang for a few seconds, setImmediate can avoid this and "maybe" make it work properly.

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

No branches or pull requests