-
Notifications
You must be signed in to change notification settings - Fork 256
Closed
Labels
bugConfirmed bugConfirmed bugreleasedThis feature/bug fix has been releasedThis feature/bug fix has been released
Description
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 bug: uv_os_gethostname on Windows 7 x64 libuv/libuv#3260
- Node bug: from Nodejs 13 breaks on Windows 7 - procedure entry point GetHostNameW could not be located (as libuv) nodejs/node#41297
- Electron bug: [Bug]: os.hostname() not implemented on Win7 Electron19 electron/electron#34404
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('')decafdennis
Metadata
Metadata
Assignees
Labels
bugConfirmed bugConfirmed bugreleasedThis feature/bug fix has been releasedThis feature/bug fix has been released