Skip to content

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

Closed

Description

@FlyingDR

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

Activity

  1. ericelliott commented on Aug 11, 2022

    @ericelliott
    Collaborator

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

  2. added a commit that references this issue on Aug 11, 2022
    4567f7d
  3. FlyingDR commented on Aug 11, 2022

    @FlyingDR
    Author

    @ericelliott Pull request is ready

  4. ericelliott commented on Aug 12, 2022

    @ericelliott
    Collaborator

    See PR comment

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions