I have my app packaged correctly and uploaded to an S3 bucket (something which I previously did with the Windows version), but the autoupdater doesn't work on mac (it works fine on Windows though).
When running my app from the terminal so I can see the logging I see this:
App is ready
Checking for update
Found version 1.0.91 (url: https://s3-eu-west-1.amazonaws.com/*****/releases/MyApp-1.0.91-mac.zip)
Downloading update from https://s3-eu-west-1.amazonaws.com/*****/releases/MyApp-1.0.91-mac.zip
{ Error: Update check failed. The server sent an invalid JSON response. Try again later.
preventDefault: [Function: preventDefault],
sender:
AutoUpdater {
_events: { error: [Function], 'update-downloaded': [Function] },
_eventsCount: 2 } }
Error: Error: Update check failed. The server sent an invalid JSON response. Try again later.
latest-mac.json contains
{
"version": "1.0.91",
"url": "https://s3-eu-west-1.amazonaws.com/*****/releases/MyApp-1.0.91-mac.zip"
}
What could be the problem?
Do you use latest electron-updater version (1.3.2)?
Sorry that I not yet have time to publish package with deprecated notice. Please use electron-updater instead.
Ah ok. It's hard for me to follow since I do development in several domains :) I'll replace it and see what happens.
I just replaced it but I have some issues
const autoUpdater = require('electron-updater')
autoUpdater.addListener("update-available", function(event) {
contents.send('updater',{msg:'update-available'})
});
Error:
Uncaught TypeError: autoUpdater.addListener is not a function
I tried looking in the docs but the only example there is in Typescript, and I don't understand Typescript.
How do I add the event listeners?
Very strange. Are you sure that autoUpdater is not null or undefined?
Looks like it should be const {autoUpdater} = require('electron-updater') or const autoUpdater = require('electron-updater').autoUpdater based on the wiki.
Figured it out by printing the object contents in the mean time. My bad. Will continue testing now.
Exactly the same error
``
Found version 1.0.93 (url: https://s3-eu-west-1.amazonaws.com/*****/releases/MyApp-1.0.93-mac.zip)
Downloading update from https://s3-eu-west-1.amazonaws.com/*****/releases/MyApp-1.0.93-mac.zip
{ Error: Update check failed. The server sent an invalid JSON response. Try again later.
preventDefault: [Function: preventDefault],
sender:
AutoUpdater {
_events: { error: [Function], 'update-downloaded': [Function] },
_eventsCount: 2 } }
Error: Error: Update check failed. The server sent an invalid JSON response. Try again later.
ERROR
What I don't understand is that it seems to read the json file correctly, it gets the correct link to the zip file and it starts downloading the update, and only during the download this JSON error is shown?
and only during the download this JSON error is shown?
because under the hood we use Squirrel.Mac and... BOO!!! all simplicity is gone and you are alone in the dark.
Well, it works for me. I will check again this week.
Is it possible for you to inspect network response? Please specify electron version.
I can run a Charles Proxy here. The problem is that Electron (running on Chromium) refuses the proxy self signed certificate so I can't inspect the network requests since they all go over SSL
Running electron 1.5.0
Ok, I managed, by hacking inside the config files of the .app bundle, to have the updater connect to a local http server that just serves static files (python http server), so now I can inspect the callls. Result is the same:
Found version 1.0.93 (url: http://localhost/MyApp-1.0.93-mac.zip)
Downloading update from http://localhost/MyApp-1.0.93-mac.zip
{ Error: Update check failed. The server sent an invalid JSON response. Try again later.
preventDefault: [Function: preventDefault],
sender:
AutoUpdater {
_events: { error: [Function], 'update-downloaded': [Function] },
_eventsCount: 2 } }
Error: Error: Update check failed. The server sent an invalid JSON response. Try again later.
Checking the network requests, it only shows a call to http://localhost/latest-mac.json
response
{
"version": "1.0.93",
"url": "http://localhost/MyApp-1.0.93-mac.zip"
}
No other calls to localhost being made.
It's as if it reads that JSON line by line and then all of the sudden misses something and bails out.
It seems to go wrong inside this:
this.nativeUpdater = require("electron").autoUpdater;
...
this.nativeUpdater.checkForUpdates();
inside MacUpdater.js
Works for me. @ir-fuel Please try to change your URL to be like https://develar.s3.amazonaws.com/onshape-test where develar is the bucket name and onshape-test is folder (in your case, it seems, it is releases).
Please ensure that access is granted as read for everyone.
Sorry, I don't understand. What is wrong with my current URL?
Did what you asked:
Found version 1.0.96 (url: https://***.s3.amazonaws.com/releases/MyApp-1.0.96-mac.zip)
Downloading update from https://***.s3.amazonaws.com/releases/MyApp-1.0.96-mac.zip
{ Error: Update check failed. The server sent an invalid JSON response. Try again later.
preventDefault: [Function: preventDefault],
sender:
AutoUpdater {
_events: { error: [Function], 'update-downloaded': [Function] },
_eventsCount: 2 } }
Error: Error: Update check failed. The server sent an invalid JSON response. Try again later.
ERROR
I have no idea. You can send me your app to investigate.
Bingo!
Sometimes it helps to walk away from the computer in order to find it.
My Product Name has spaces in it, therefore the generated JSON file also has spaces in the URL.
I manually edited the JSON file on S3 and replaced the spaces with %20 and it works!
The yml file for my windows updates also contains the spaces in the file name, but it seems that isn't a problem as I guess you build the URL yourself from the filename.
So I guess it would be a good idea to URLEncode the filename that is put in latest-mac.json before upload.
That was a productive day ...
Impressive, quit/reinstall/launch is instant on mac.
On Windows it takes 30 seconds.
Impressive, quit/reinstall/launch is instant on mac.
Yes, Windows is slow, insecure, outdated and unusable OS. macOS is much better.
Yes, we can also "just copy" as macOS does, but as Windows just * (including IO), shortcuts and other stuff requires explicit registration (on macOS implicit Info.plist doesn't require any system calls to install app).
Most helpful comment
Looks like it should be
const {autoUpdater} = require('electron-updater')orconst autoUpdater = require('electron-updater').autoUpdaterbased on the wiki.