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

@bugsnag/electron does not work with Windows 7 and Electron 19+ #1783

Closed
jeremyspiegel opened this issue Jul 6, 2022 · 8 comments
Closed
Labels
bug Confirmed bug released This feature/bug fix has been released

Comments

@jeremyspiegel
Copy link

Describe the bug

The os.hostname() node API throws on Windows 7 with Electron 19+ with a uv_os_gethostname returned ENOSYS error. This API is used in @bugnsag/cuid/lib/fingerprint.js, and causes a crash on startup.

libuv and node don't support Windows 7, so those projects seem very unlikely address this. Electron claims support for Windows 7 but it's unclear if they will address this or not (currently looking like not).

I was able to address this in my project with this patch:

diff --git a/node_modules/@bugsnag/cuid/lib/fingerprint.js b/node_modules/@bugsnag/cuid/lib/fingerprint.js
index 5f9f765..ab1a3a7 100644
--- a/node_modules/@bugsnag/cuid/lib/fingerprint.js
+++ b/node_modules/@bugsnag/cuid/lib/fingerprint.js
@@ -1,9 +1,17 @@
 var pad = require('./pad.js');
 
+function tryGetHostname() {
+  try {
+    return os.hostname();
+  } catch (err) {
+    return '';
+  }
+}
+
 var os = require('os'),
     padding = 2,
     pid = pad(process.pid.toString(36), padding),
-    hostname = os.hostname(),
+    hostname = tryGetHostname(),
     length = hostname.length,
     hostId = pad(hostname
       .split('')
@luke-belton
Copy link
Member

Hi @jeremyspiegel - thanks for raising this and sharing your solution. We're going to investigate and look at releasing a fix. We'll make sure we keep you updated on this thread 👍

@luke-belton luke-belton added bug Confirmed bug backlog We hope to fix this feature/bug in the future labels Jul 7, 2022
@NemoAlex
Copy link

NemoAlex commented Jul 31, 2022

I have made a test on Electron Fiddle:
https://gist.github.com/NemoAlex/431a61e8464ee6d606f3a02868c66017
Electron 19 Binary uses Node.js 16.14.2, maybe version before 16.14.0(libuv 1.42.0) was fine.
Such as Electron 18 uses Node.js 16.13.2, can pass the test.
https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V16.md

@FlyingDR
Copy link

FlyingDR commented Aug 9, 2022

I've filled in separate issue #1799 before finding this one, it is directly related.

I will close it in favor of this one but want to mention it due to the reference to another possible place where the affected function is being called.

@jeanfbrito
Copy link

@luke-belton Hello! Any news about this? Our app started crashing on Windows 7 because of this.
I will try disabling Bugsnag to see if it will solve the problem for now.

@Tulipesz
Copy link

Tulipesz commented Aug 31, 2022

Eu fiz um teste no Electron Fiddle: https://gist.github.com/NemoAlex/431a61e8464ee6d606f3a02868c66017 Electron 19 Binary usa Node.js 16.14.2, talvez a versão anterior a 16.14.0 (libuv 1.42.0) estivesse bem. Como o Electron 18 usa Node.js 16.13.2, pode passar no teste. https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V16.md

I was looking into the problem with electron in general and downgrading to electron in version 18 fixed the error!
Thx very much!

@FlyingDR
Copy link

@Tulipesz The reason of the issue is the use of cuid library in Bugsnag. I've already sent PR paralleldrive/cuid#264 to the original library, but it is not merged yet.

Bugsnag maintains its own fork: https://github.com/bugsnag/cuid, so hopefully, they will update it too. @luke-belton Maybe you will consider porting proposed change to your fork? It was approved in general by the library author.

In meantime, I've solved the issue for myself by using patch-package

@jeremyspiegel
Copy link
Author

Looks like this was fixed in Electron via electron/electron#35219.

@johnkiely1
Copy link
Member

Just to let you know we have now released v3.0.2 of bugsnag/cuid which includes the changes mentioned above, so this issue should now be fixed.

@johnkiely1 johnkiely1 added released This feature/bug fix has been released and removed backlog We hope to fix this feature/bug in the future labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug released This feature/bug fix has been released
Projects
None yet
Development

No branches or pull requests

7 participants