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 error #6170

Closed
nikcheerla opened this issue Aug 20, 2021 · 12 comments · Fixed by webcatalog/webcatalog-legacy#1500, webcatalog/chromeless#65 or #6149

Comments

@nikcheerla
Copy link
Contributor

  • 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 (so bleeding edge)
  • Target:
  • Apple Intel Macs and Apple M1 Macs
Error: TypeError: Cannot read property 'port' of null
    at getServerUrl (/Users/nikcheerla/Projects/nooks-electron/node_modules/electron-updater/out/MacUpdater.js:76:48)
    at MacUpdater.updateDownloaded (/Users/nikcheerla/Projects/nooks-electron/node_modules/electron-updater/out/MacUpdater.js:78:80)
    at Object.done (/Users/nikcheerla/Projects/nooks-electron/node_modules/electron-updater/out/MacUpdater.js:60:33)
    at done (/Users/nikcheerla/Projects/nooks-electron/node_modules/electron-updater/out/AppUpdater.js:486:31)
    at async MacUpdater.executeDownload (/Users/nikcheerla/Projects/nooks-electron/node_modules/electron-updater/out/AppUpdater.js:496:20)

I get this error when I call autoUpdater.downloadUpdate() in my electron application. it used to work consistently until i upgraded from 4.3.9 to 4.4.5 (which had an urgent bugfix I needed for developing on M1 macs.) Now all our users are stranded on their old version of our application because they can't download updates. Any ideas why this happened and how to fix?

@mmaietta
Copy link
Collaborator

That should be fixed via this PR
#6149

@nikcheerla
Copy link
Contributor Author

@mmaietta how did something like this slip in? Is the most recent version of electron-builder published on npm not always stable?

Also does this break for every release server or just certain types of release servers? In our currently deployed electron app, we can change the release server we pull from easily, but we can't downgrade the package version of electron-updater without deploying a new electron version (which they won't receive because updating is broken 😢.) It would be extremely helpful to be able to change the release server and make updating work, rather than having to force all our users to uninstall and install a new version of the app.

@mmaietta
Copy link
Collaborator

Is the most recent version of electron-builder published on npm not always stable?

Latest version (also known as stable) is 4.3.9.
Bugs can make it into the "bleeding edge", such as with 4.4.5. In this case, more logging was added, but rather, it wasn't known that a port would throw a null error if the server wasn't already listening. The null bug was due to a force casting,

const address = server.address() as AddressInfo

This obfuscated the fact that address() returns AddressInfo | string | null; The docs during implementation were also ignored as it shows in @types/http:

server.address() returns null before the 'listening' event has been

Honestly, this one should have been on the developer to have known/checked. I don't think it would have been caught in a standard PR review.

Strict eslinting and typescript only cover so far, but it doesn't hide aspects that require that deeper level of contextual knowledge. That being said, I'd like to see if there's anything in the eslint/typescript ecosystem that can check these forced type-casts to make sure they're not hiding any potential null values.
Do you happen to know of any tools we could use for that by chance? It'd be significantly helpful for preventing issues like this in the future

@aguynamedben
Copy link
Contributor

This was a painful one for us. Luckily we caught it right after a deploy, but it would have broken autoupdates for all of our users.

@aguynamedben
Copy link
Contributor

@mmaietta How can we tell which version is stable? We've just been following along with the releases assuming they're all stable, since they all make it to npm.

@aguynamedben
Copy link
Contributor

I see "pre-release" vs. "latest" tag on the Releases page: https://github.com/electron-userland/electron-builder/releases

@mmaietta
Copy link
Collaborator

mmaietta commented Sep 5, 2021

Hi @aguynamedben
latest (github and npm) = stable
pre-release = bleeding edge (also known as next on npm)

@aguynamedben
Copy link
Contributor

Is anybody seeing this on electron-updater 4.4.6? We're still investigating, but we did an alpha build of our app with electron-updater bumped to 4.4.6 and seem to still be seeing this error when trying auto-updates from a build with electron-updater 4.4.6.

I'll report back, but we're scratching our heads to make sure 4.4.6 fixes the error.

@mmaietta
Copy link
Collaborator

@aguynamedben is it the same error message? Have you been able to repro?

@aguynamedben
Copy link
Contributor

@mmaietta We are not seeing this on 4.4.6. My bad! We had a bad build that had 4.4.5 (bad version) even though the intention was for it to have 4.4.6. We're not seeing this error on 4.4.6, and given our review of the change do not expect to see it on 4.4.6 or higher.

@jeffcrouse
Copy link

I'm a little confused. I'm seeing this error in 4.3.9.
Wire 2021-09-28 at 8_10 AM

Which version should I update to? 4.4.3?

@aguynamedben
Copy link
Contributor

4.4.6 has it fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment