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

Auto-updater with Amazon S3 #1310

Closed
dventurino opened this issue Feb 28, 2017 · 32 comments · May be fixed by qcif/data-curator#563
Closed

Auto-updater with Amazon S3 #1310

dventurino opened this issue Feb 28, 2017 · 32 comments · May be fixed by qcif/data-curator#563

Comments

@dventurino
Copy link

  • electron-builder v14.5.2
  • electron-updater v1.7.1

I'm having trouble setting the auto update process. I'm publishing my artifact on Amazon S3 correctly (and the auto-generated latest.yml as well). The folders are public.

I followed the wiki on how to implement the Auto-Updater and I see that I have the app-update.yml file in my resources folder, but when I start my application I get the

Checking for update...

message, but then I get no response about if there is an update available or not.

The latest.yml file contains the following fields:

version: 1.0.0
releaseDate: '2017-02-28T10:52:24.778Z'
githubArtifactName: my-Setup-1.0.0.exe
path: my_Setup_1.0.0.exe
sha2: 5a7459ca7bf33808e43803df72961584124ec42d28a2343d1bf62d4006c258e7

while the app-update.yml file in my resources folder contains:

provider: s3
bucket: my_bucket_name
path: path/to/my/files

The package.json looks like this:

...
"win": {
      "icon": "./img/icon.ico",
      "target": [
        "nsis"
      ],
      "publish": {
        "provider": "s3",
        "bucket": "my_bucket_name",
        "path": "path/to/my/files"
      }
    },
    "nsis": {
      "artifactName": "${productName}_Setup_${version}.${ext}",
      "installerIcon": "./img/installer_logo.ico"
    },
...

What am I doing wrong?

@develar
Copy link
Member

develar commented Feb 28, 2017

@dventurino
Copy link
Author

Unfortunately that does not give much more information:

[2017-02-28 12:13:05:0000] [info] Checking for update

This is the only line in the log file.

Re-looking at the latest.yml file...is it ok that I have a field named githubArtifactName even though I'm using s3 ?

@develar
Copy link
Member

develar commented Feb 28, 2017

is it ok that I have a field named githubArtifactName even though I'm using s3 ?

Yes. Because you can set any provider in runtime.

This is the only line in the log file.

Hmm... Is it possible for you to check is auto update works on macOS?

@develar
Copy link
Member

develar commented Feb 28, 2017

Please run your app in the terminal (cmd).

set DEBUG=electron-builder
path_to_your_app.exe

and attach output here.

@dventurino
Copy link
Author

Output on Windows, launched from cmd:

$ set DEBUG=electron-builder

$ ./dist/win-unpacked/box.exe

Wait for app ready

starting server on  /tmp/app.boxMainProcess
starting TLS server false
starting server as Unix || Windows Socket
[12:23:36:0159] [info] Checking for update


@dventurino
Copy link
Author

I'm trying to set up the auto update on macOS as well...I wasn't working on it yet

@develar
Copy link
Member

develar commented Feb 28, 2017

electron version?

@dventurino
Copy link
Author

electron v.1.4.5

I set up the auto update on macOS and I have the same situation...it did not upload the latest-mac.json file though, but I'm not sure if it had to since I'm using dmg as target and not zip.

@develar
Copy link
Member

develar commented Feb 28, 2017

electron v.1.4.5

Please upgrade to 1.4.15 or even to latest 1.6.1

@dventurino
Copy link
Author

Tried both v1.4.15 and v1.6.1 with no luck

@dventurino
Copy link
Author

I also upgraded electron-updater to v1.8.0

@dventurino
Copy link
Author

dventurino commented Feb 28, 2017

Now I get some output with

set DEBUG=electron-builder

$ ./dist/win-unpacked/box.exe

Wait for app ready

starting server on  /tmp/app.boxMainProcess
starting TLS server false
starting server as Unix || Windows Socket
(node:2984) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object]
(node:2984) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:2984) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): [object Object]
(node:2984) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): [object Object]
(node:2984) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): [object Object]
(node:2984) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): [object Object]
(node:2984) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): [object Object]


@dventurino
Copy link
Author

dventurino commented Feb 28, 2017

Don't know it this will help, but adding the following lines

 autoUpdater.checkForUpdates().then(
        function (val) {
            log.info('Promise fulfilled');
        }).catch(
        function (reason) {
            log.error('Handle rejected promise (' + reason + ') here.');
        });

I get this error in my logs:

ERROR Handle rejected promise (ReferenceError: sendStatus is not defined) here.

@develar
Copy link
Member

develar commented Feb 28, 2017

@dventurino Cool. Could you please change

log.error('Handle rejected promise (' + reason + ') here.');

to log.error('Handle rejected promise (' + reason.stack || reason + ') here.');

@dventurino
Copy link
Author

Yep!

INFO Checking for update
ERROR Handle rejected promise (ReferenceError: sendStatus is not defined
    at NsisUpdater.autoUpdater.on (C:\Users\Daniele\git\box\dist\win-unpacked\resources\app.asar\main.js:228:5)
    at emitNone (events.js:86:13)
    at NsisUpdater.emit (events.js:185:7)
    at C:\Users\Daniele\git\box\dist\win-unpacked\resources\app.asar\node_modules\electron-updater\src\AppUpdater.ts:140:10
    at Generator.next (<anonymous>)
    at runCallback (timers.js:651:20)
    at tryOnImmediate (timers.js:624:5)
    at processImmediate [as _immediateCallback] (timers.js:596:5)
From previous event:
    at NsisUpdater._checkForUpdates (C:\Users\Daniele\git\box\dist\win-unpacked\resources\app.asar\node_modules\electron-updater\out\AppUpdater.js:191:11)
    at NsisUpdater.checkForUpdates (C:\Users\Daniele\git\box\dist\win-unpacked\resources\app.asar\node_modules\electron-updater\src\AppUpdater.ts:124:35)
    at Timeout._onTimeout (C:\Users\Daniele\git\box\dist\win-unpacked\resources\app.asar\main.js:252:17)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

@develar
Copy link
Member

develar commented Feb 28, 2017

@dventurino Could you please post your code where do you use updater?

@dventurino
Copy link
Author

dventurino commented Feb 28, 2017

autoUpdater.on('checking-for-update', () => {
    sendStatus('Checking for update...');
})
autoUpdater.on('update-available', (ev, info) => {
    sendStatus('Update available.');
})
autoUpdater.on('update-not-available', (ev, info) => {
    sendStatus('Update not available.');
})
autoUpdater.on('error', (ev, err) => {
    sendStatus('Error in auto-updater.');
})
autoUpdater.on('download-progress', (ev, progressObj) => {
    sendStatus('Download progress...');
    log.info('progressObj', progressObj);
})
autoUpdater.on('update-downloaded', (ev, info) => {
    sendStatus('Update downloaded.  Will quit and install in 5 seconds.');
    // Wait 5 seconds, then quit and install
    setTimeout(function () {
        autoUpdater.quitAndInstall();
    }, 5000)
})
// Wait a second for the window to exist before checking for updates.
setTimeout(function () {
    autoUpdater.checkForUpdates().then(
        function (val) {
            log.info('Promise fulfilled');
        }).catch(
        function (reason) {
            log.error('Handle rejected promise (' + reason.stack || error + ') here.');
        });
}, 1000);

Replacing "sendStatus" with "log.info" made it work!

@develar
Copy link
Member

develar commented Feb 28, 2017

Well... error in your code. It seems sendStatus is not defined.

But! AppUpdater must handle errors during emit and report it properly.

@develar
Copy link
Member

develar commented Feb 28, 2017

You don't need to listen all events to log. electron-updater opposite to built-in electron updater handles it for you. You can listen only required for you events.

@dventurino
Copy link
Author

Damn! I didn't see the function definition in the example https://github.com/iffy/electron-updater-example/blob/master/main.js.

Which part of the code above should I remove ?

@develar
Copy link
Member

develar commented Feb 28, 2017

@iffy I suggest to remove sendStatus to keep example as simple as possible.

@iffy
Copy link
Contributor

iffy commented Feb 28, 2017

Hmmm... Should we get rid of the window, too, then? Perhaps this could be fixed by renaming sendStatus to something like logStatusToWindow with a comment next to each line stating that it's not necessary. I think taking it out makes it really hard to tell what's going on. Oh, wait... I have an even better idea. I'll submit a PR in about an hour.

@develar
Copy link
Member

develar commented Feb 28, 2017

it really hard to tell what's going on.

Just enable logging :)

@dventurino
Copy link
Author

@iffy you could also keep the example as is...it was my fault not to check where the function came from

@develar
Copy link
Member

develar commented Feb 28, 2017

@dventurino I also didn't notice this function during review :( So, I suggest to simplify example.

@dventurino
Copy link
Author

Anyway, it's working now on Windows. Thank you so much for your help!

On macOS I have the same problem as in #1261 with electron-builder v14.5.2

@develar
Copy link
Member

develar commented Feb 28, 2017

On macOS I have the same problem as in #1261 with electron-builder v14.5.2

Do you use default target or custom?

@dventurino
Copy link
Author

I was using

"mac": {
     ...
     "target": [
       "dmg"
     ],
...

Removing it solved the problem. It generates a zip that I'm not gonna use though.

@develar
Copy link
Member

develar commented Feb 28, 2017

It generates a zip that I'm not gonna use though.

This zip is required for Squirrel.Mac. So, you must use it and it will be uploaded. Sadly, but true.

@dventurino
Copy link
Author

Oh, okay ;) it's no trouble! Thanks again and sorry for the off-topic.

@iffy
Copy link
Contributor

iffy commented Feb 28, 2017

@develar iffy/electron-updater-example#10 shows my suggested fix. I think having the window show you what's going on will help new people, but I've separated what's actually required out from the windowing parts.

This was referenced Mar 1, 2017
@dkapanidis
Copy link

This zip is required for Squirrel.Mac. So, you must use it and it will be uploaded. Sadly, but true.

Gosh, this should be somewhere in the documentation. I've been banging my head to find why the latest-mac.json was not published when I removed the zip target.

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