Skip to content

Commit

Permalink
Merge pull request #5 from bugsnag/win7-hostname-fallback
Browse files Browse the repository at this point in the history
Fall back to using environment variables when os.hostname fails
  • Loading branch information
yousif-bugsnag authored Nov 25, 2022
2 parents 4af4f8c + affecd8 commit 526a418
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/fingerprint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ function getHostname () {
try {
return os.hostname();
} catch (e) {
return '';
/**
* This is most likely Windows 7 which is known to cause os.hostname() to break
* @see https://github.com/nodejs/node/issues/41297
* @see https://github.com/libuv/libuv/issues/3260
*
* Fallback to take hostname from environment variables
* @see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/hostname#notes
*/
// eslint-disable-next-line no-underscore-dangle
return process.env._CLUSTER_NETWORK_NAME_ || process.env.COMPUTERNAME || 'hostname';
}
}

Expand Down

0 comments on commit 526a418

Please sign in to comment.