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

Cannot read property 'port' of null at getServerUrl -- any way to fix without updating electron app? #6177

Closed
nikcheerla opened this issue Aug 23, 2021 · 6 comments · Fixed by #6149

Comments

@nikcheerla
Copy link
Contributor

nikcheerla commented Aug 23, 2021

  • Electron-Builder Version:
    22.11.4
  • Node Version:
    v16.6.1
  • Electron Version:
  • Electron Type (current, beta, nightly):
    13.1.6
    current

4.4.5

  • Target:
    Mac (intel and M1)

So I mentioned this in #6170 but I'm having a major issue with electron-updater just completely failing to download an update because of the 'Cannot read property port of null' issue. Unfortunately, we shipped the latest version production app to our users with this update code, so we can't deploy an update to fix the update issue! Our users are effectively stranded on the last version of the electron app we released.

I still don't completely understand the bug, does this mean that all updates everywhere in electron-updater are broken? Is there some type of release server that would still work?

We have access to remote.autoUpdater from the frontend, so we can e.g set the feed URL or something for autoUpdater, not sure if that will help though.

Any ideas for how we can possibly fix electron auto updating without having to do an update electron side? Has anyone dealt with an issue like this before with electron-updater? I just donated, this is super important to us to fix soon and would love any help any of you could provide.

@ezekg
Copy link
Contributor

ezekg commented Aug 23, 2021

Just spitballing here — since it sounds like you're able to set the feed URL of the native Electron auto-updater from the front-end, you could potentially inject an update script that points to a URL to download a specific JSON payload supported by Squirrel that specifies a patched release. This would only work for Mac, not sure how to do the same on Windows.

One note: you would need to specify the serverType when using the JSON server format:

autoUpdater.setFeedURL({
  url: 'https://example.com/emergency-patch.json',
  serverType: 'json',
})

autoUpdater.checkForUpdates()

Honestly, I'm not even really sure if that would work. It would depend on your app's security model, I'd assume. But it might be worth exploring since you mentioned it.

@nikcheerla
Copy link
Contributor Author

Interesting -- i'll definitely try it out! Luckily our app is only available for MacOS right now. I was thinking something along those lines, but I didn't know the format accepted by Squirrel, so thanks for pointing me to those docs :)

@mmaietta
Copy link
Collaborator

Thanks for jumping in here @ezekg, really appreciate it!

This would only work for Mac, not sure how to do the same on Windows.

Coincidentally, this null port bug is isolated purely to the MacUpdater.

@nikcheerla, please let us know if you're able to make progress with that route. Regarding one of your other questions, I've never seen an issue like this occur before. It's also rare that dev work is done in electron-updater though, most of the time it's in the app builder flow.
Quick Q: Are you able to release FE updates separate from electron (shell) updates? Or are your FE+shell updates tied together?

@nikcheerla
Copy link
Contributor Author

Quick Q: Are you able to release FE updates separate from electron (shell) updates? Or are your FE+shell updates tied together?

Yup, I'm able to release frontend updates separately from electron shell updates!

@nikcheerla
Copy link
Contributor Author

@ezekg the setFeedURL approach works! There are some small caveats (for example, we can never know when the update actually finished downloading in Squirrel, which is a little annoying), but in general running that with a JSON server I created, waiting 30 seconds, then calling quitAndInstall() seems to reliably update. Thanks for the suggestion!

@mmaietta I want to update to the latest version of electron-updater still so I can get in the M1 updating fix, but I want to make sure it actually works this time :) How will I know when 4.4.6 is stable?

@mmaietta
Copy link
Collaborator

I'm not familiar with any standardized process (for electron-builder or any package really), I figured 'next' versions are only marked 'latest' after being deployed in the wild for a month or so.

Being open source with active community contributions (💪🏻), I can't guarantee release regression suites on par with public companies. That being said, I do believe 4.5.0 to be quite stable, especially with the fix you are needing for Mac.

I'm actually working on adding more electron-updater integration tests as one of my next tasks, found that there's a few blind spots that have been there for a long time.

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