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

Autoupdater problem on mac if space in the name #1192

Closed
ir-fuel opened this issue Jan 31, 2017 · 24 comments · May be fixed by qcif/data-curator#563
Closed

Autoupdater problem on mac if space in the name #1192

ir-fuel opened this issue Jan 31, 2017 · 24 comments · May be fixed by qcif/data-curator#563

Comments

@ir-fuel
Copy link

ir-fuel commented Jan 31, 2017

  • Version: 12.0.3
  • Target: Mac

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?

@develar
Copy link
Member

develar commented Jan 31, 2017

Do you use latest electron-updater version (1.3.2)?

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

I am using this:

https://www.npmjs.com/package/electron-auto-updater

v1.0.0

@develar
Copy link
Member

develar commented Jan 31, 2017

Sorry that I not yet have time to publish package with deprecated notice. Please use electron-updater instead.

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

Ah ok. It's hard for me to follow since I do development in several domains :) I'll replace it and see what happens.

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

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?

@develar
Copy link
Member

develar commented Jan 31, 2017

Very strange. Are you sure that autoUpdater is not null or undefined?

@ExPixel
Copy link

ExPixel commented Jan 31, 2017

Looks like it should be const {autoUpdater} = require('electron-updater') or const autoUpdater = require('electron-updater').autoUpdater based on the wiki.

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

Figured it out by printing the object contents in the mean time. My bad. Will continue testing now.

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

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
`

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

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?

@develar
Copy link
Member

develar commented Jan 31, 2017

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.

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

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

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

Running electron 1.5.0

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

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.

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

It seems to go wrong inside this:

        this.nativeUpdater = require("electron").autoUpdater;
...
        this.nativeUpdater.checkForUpdates();

inside MacUpdater.js

@develar
Copy link
Member

develar commented Jan 31, 2017

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.

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

Sorry, I don't understand. What is wrong with my current URL?

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

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

@develar
Copy link
Member

develar commented Jan 31, 2017

I have no idea. You can send me your app to investigate.

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

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 ...

@ir-fuel
Copy link
Author

ir-fuel commented Jan 31, 2017

Impressive, quit/reinstall/launch is instant on mac.
On Windows it takes 30 seconds.

@develar
Copy link
Member

develar commented Feb 1, 2017

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).

@develar develar changed the title Autoupdater problem on mac Autoupdater problem on mac if space in the name Feb 1, 2017
@develar develar closed this as completed in e5d58e2 Feb 1, 2017
@alex-drocks
Copy link

alex-drocks commented Jan 28, 2021

Thanks for this!

I also had spaces in my zip file name and encoding them fixed the Electron autoUpdater's invalid json response error message.

My server is in php so I simply used rawurlencode($latestVersionFileName) which ends up looking like this:
Finance%20D%20-%20Tenue%20de%20livres-darwin-x64-0.9.5.zip

autoUpdater now works.

@SalmeronU
Copy link

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 ...

Yes! electron-builder was creating the files with spaces in the name, my update server was replacing the spaces with '.' and latest.yml files were replacing spaces with '-'
Just renamed the files so they would match the path from latest.yml and it worked

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.

5 participants