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

Use of os.hostname() causes runtime crash on Wndows 7 #263

Closed
FlyingDR opened this issue Aug 9, 2022 · 3 comments · May be fixed by #264
Closed

Use of os.hostname() causes runtime crash on Wndows 7 #263

FlyingDR opened this issue Aug 9, 2022 · 3 comments · May be fixed by #264
Labels

Comments

@FlyingDR
Copy link

FlyingDR commented Aug 9, 2022

Hello,

At this moment library relies on the use of os.hostname() as a part of the fingerprint generator for Node.js:

https://github.com/ericelliott/cuid/blob/fb9bb90644110474253bf8e03fbf26668cd105c0/lib/fingerprint.js#L6

This method is broken on Windows 7 due to nodejs/node#25111 with a root cause libuv/libuv#3260.

Since your library is quite popular and required change is very small - I would want to propose to avoid using os.hostname() on affected platform.

Example patch may look like this:

--- lib/fingerprint.js
+++ lib/fingerprint.js
@@ -3,7 +3,7 @@ var pad = require('./pad.js');
 var os = require('os'),
     padding = 2,
     pid = pad(process.pid.toString(36), padding),
-    hostname = os.hostname(),
+    hostname = os.version().indexOf('Windows 7 ') === 0 ? 'windows7' : os.hostname(),
     length = hostname.length,
     hostId = pad(hostname
       .split('') 
@ericelliott
Copy link
Collaborator

Please open a PR and link to this issue in the description.

@FlyingDR
Copy link
Author

@ericelliott Pull request is ready

@ericelliott
Copy link
Collaborator

See PR comment

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

Successfully merging a pull request may close this issue.

2 participants