Electron-builder: Auto updater with s3 provider on a private bucket fails on electron 7.1.1.

Created on 23 Nov 2019  路  7Comments  路  Source: electron-userland/electron-builder


  • Version: 21.2.0
  • electron: 7.1.1
  • electron-updater: 4.2.0
  • Target: macOS 10.15


Autoupdate with s3 fails.

autoUpdater.on("checking-for-update", () => {
  log.info(updateLog, "Checking for update...");
  let opts = {
    service: 's3',
    region: 'us-west-1',
    host: 'abc.s3-us-west-1.amazonaws.com',
    path: process.platform === 'win32' ? '/latest.yml' : '/latest-mac.yml'
  }
  aws4.sign(opts, {
    accessKeyId: ACCESSKEY,
    secretAccessKey: SECRETKEY,
  })
  autoUpdater.requestHeaders = opts.headers
});
autoUpdater.on("error", (ev, err) => {
    log.error(updateLog, "Error in auto-updater: ", err);
});

package.json

"build": {
    "publish": {
      "provider": "s3",
      "region": "us-west-1",
      "bucket": "abc",
      "acl": "private",
      "channel": "latest",
      "encryption": "AES256",
      "publishAutoUpdate": "true"
    },
  },

This prints:

[info] [AUTOUPDATE]  Checking for update...
[error] [AUTOUPDATE]  Error in auto-updater: Cannot check for updates: Error: net::ERR_INVALID_ARGUMENT
[info] Handle rejected promise (Error: net::ERR_INVALID_ARGUMENT) here.

Works fine with:

  • Version: 21.2.0
  • electron: 6.0.4
  • electron-updater: 4.2.0

Happy to contribute if you can point me in the right direction. Thanks

backlog

Most helpful comment

This is still broken on electron 8. Is there no way to use s3 with acl:private with updater? Thanks

All 7 comments

I suppose you're using aws-sdk to connect to your Amazon bucket. Make sure that all the environment variables are set and that you can successfully connect to your Amazon bucket.

I can connect successfully to the bucket. The above code works unchanged on electron 6:

  • electron-builder: 21.2.0
  • electron: 6.1.5
  • electron-updater: 4.2.0
  • Target: macOS 10.15
    .checkForUpdates()
    .then(function(val) {
      log.info('Promise fulfilled ', val)
    })
    .catch(function(reason) {
      log.info('Handle rejected promise (' + reason + ') here.')
    })

prints:

[2019-11-24 15:26:29.657] [info] [AUTOUPDATE]  Checking for update...
[2019-11-24 15:26:30.192] [info] [AUTOUPDATE]  Update not available.
[2019-11-24 15:26:30.194] [info] Promise fulfilled {
  versionInfo: {
    version: '0.1.2',
    files: [ [Object], [Object] ],
    path: 'App-0.1.2-mac.zip',
    sha512: 'Yefa/8Dq+rBpfuuL3iAa1euC/vW8PWOAAAETqPROn0zHwhWb+iYE1YW22Mw0SPvywsRbHoqPB1f/haXpyEZAnA==',
    releaseDate: '2019-11-22T18:15:24.485Z'
  },
  updateInfo: {
    version: '0.1.2',
    files: [ [Object], [Object] ],
    path: 'App-0.1.2-mac.zip',
    sha512: 'Yefa/8Dq+rBpfuuL3iAa1euC/vW8PWOAAAETqPROn0zHwhWb+iYE1YW22Mw0SPvywsRbHoqPB1f/haXpyEZAnA=='',
    releaseDate: '2019-11-22T18:15:24.485Z'
  }
}

As it been said on the Google Chrome GitHub (Electron uses Chromium as it's base, the 'open-source' Google Chrome), seems that they dropped the 'host' parameter. I think this might be why this code doesn't work.

(But apparently, since electron 7+, the net functionality is a bit buggy...)

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This is still broken on electron 8. Is there no way to use s3 with acl:private with updater? Thanks

So is there any way to AutoUpdate an Electron App with s3 or should I keep searching for another way?

I am using S3 with acl: private
electron: 8.1
electron-updater: 4.2.4
target: nsis (windows 10)

I am setting the headers with aws4 signing and aws-sdk:
{Host: s3.region.amazonaws.com, 'X-Amx-Content-Sha256': XXXXXXXX, 'X-Amx-Date': 'YYYYMMDDTHHddmmZ', Authorization: 'AWS4-HMAC-SHA256 Credential=XXX, SignedHeareds=XXXX, Signature=XXXX'}

I have been doing some reading and everything points to changes introduced in how Electron implements net from version 7.

electron-updater using electron's net: https://github.com/electron-userland/electron-builder/blob/c01b7c0b55d3466b826ea9cc9a11ad34118801c1/packages/electron-updater/src/electronHttpExecutor.ts#L54

I guess some agument passed in "options" is not valid, and we get the error in auto-updater:
ERR_INVALID_ARGUMENT

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NPellet picture NPellet  路  3Comments

leo picture leo  路  3Comments

philcockfield picture philcockfield  路  3Comments

popod picture popod  路  3Comments

jhg picture jhg  路  3Comments