Skip to content

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

@jeremyspiegel

Description

@jeremyspiegel

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('')

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bugreleasedThis feature/bug fix has been released

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions