From 4567f7da858f1a59afbd25a4b2d3929c10959e08 Mon Sep 17 00:00:00 2001 From: Alexander Grimalovsky Date: Thu, 11 Aug 2022 12:45:48 +0300 Subject: [PATCH 1/7] Fingerprint calculation is updated to avoid exceptions on Windows 7. Fixes #263 --- lib/fingerprint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fingerprint.js b/lib/fingerprint.js index 5f9f7655..b8f12f5e 100644 --- a/lib/fingerprint.js +++ b/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('') From a1a0046454dfe9f2733b93c5d10c9336fdf22e1f Mon Sep 17 00:00:00 2001 From: Alexander Grimalovsky Date: Fri, 12 Aug 2022 13:53:35 +0300 Subject: [PATCH 2/7] Better implementation of retrieval of the hostname in a case if os.hostname() fails --- lib/fingerprint.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/fingerprint.js b/lib/fingerprint.js index b8f12f5e..3cd086fb 100644 --- a/lib/fingerprint.js +++ b/lib/fingerprint.js @@ -1,9 +1,26 @@ var pad = require('./pad.js'); +var os = require('os'); -var os = require('os'), - padding = 2, +function getHostname () { + try { + return os.hostname(); + } catch (e) { + /** + * 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'; + } +} + +var padding = 2, pid = pad(process.pid.toString(36), padding), - hostname = os.version().indexOf('Windows 7 ') === 0 ? 'windows7' : os.hostname(), + hostname = getHostname(), length = hostname.length, hostId = pad(hostname .split('') From 356ecb3988b37b9397352fa2005aa725ed375f4e Mon Sep 17 00:00:00 2001 From: Alexander Grimalovsky Date: Wed, 31 Aug 2022 12:25:12 +0300 Subject: [PATCH 3/7] Travis CI configuration is updated to use supported versions of OS and Node.js for tests --- .travis.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8eb0dacc..6beacc25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,17 @@ -dist: trusty +dist: bionic sudo: required language: node_js node_js: - - "6" - - "8" - - "9" + - "14" + - "16" + - "18" addons: firefox: latest + chrome: stable apt: - sources: - - google-chrome packages: - - google-chrome-stable fluxbox + - fluxbox before_script: - "export DISPLAY=:99.0" From 8cb9c97895f517cf405c1843d480eecc72c538b0 Mon Sep 17 00:00:00 2001 From: Eric Elliott Date: Wed, 7 Sep 2022 17:00:45 -0700 Subject: [PATCH 4/7] Update fingerprint.js --- lib/fingerprint.js | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/fingerprint.js b/lib/fingerprint.js index 3cd086fb..efb1cad4 100644 --- a/lib/fingerprint.js +++ b/lib/fingerprint.js @@ -2,33 +2,33 @@ var pad = require('./pad.js'); var os = require('os'); function getHostname () { - try { - return os.hostname(); - } catch (e) { - /** - * 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'; - } + try { + return os.hostname(); + } catch (e) { + /** + * 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'; + } } var padding = 2, - pid = pad(process.pid.toString(36), padding), - hostname = getHostname(), - length = hostname.length, - hostId = pad(hostname - .split('') - .reduce(function (prev, char) { - return +prev + char.charCodeAt(0); - }, +length + 36) - .toString(36), - padding); + pid = pad(process.pid.toString(36), padding), + hostname = getHostname(), + length = hostname.length, + hostId = pad(hostname + .split('') + .reduce(function (prev, char) { + return +prev + char.charCodeAt(0); + }, +length + 36) + .toString(36), + padding); module.exports = function fingerprint () { return pid + hostId; From 76791c88573148ae19c3544a658505e3ebf58f03 Mon Sep 17 00:00:00 2001 From: Eric Elliott Date: Wed, 7 Sep 2022 17:07:34 -0700 Subject: [PATCH 5/7] Update .travis.yml --- .travis.yml | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6beacc25..6a57158d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,11 @@ -dist: bionic -sudo: required language: node_js -node_js: - - "14" - - "16" - - "18" +node_js: "stable" -addons: - firefox: latest - chrome: stable - apt: - packages: - - fluxbox +dist: bionic -before_script: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - sleep 3 - - fluxbox >/dev/null 2>&1 & +before_install: + - stty cols 80 -env: - global: - - secure: ZaVxQhRv9HYXTCqeS9T4XXGO1cGayL11os8jDZ6wqNkQAwkOw3QSL70iloN5DMzg4WXv8Pwp5I4EUDIcUwiu4UCbDgfn1vYoTfVEmDMBDni4xw3CRG7IT8gEijJItCaOdEzC+IBmpAFuVI8xcuic7WBYPKRnShWkZ1xwmHDSenc= - - secure: lh7gaH4G4RUvdjrocupakeFbx4JtF7AyLGXGfsJl+/PJFjvrB+Ahatb8sTcb5hDHTr+Ucunzawx1HBNE+k+7CyykKBQpsQNWT/q6vlL/PAjRpt501O46NEdfTm/RSTqHgIo9WINYIa/ZpCh2L0vAevduaT0GGFCaP9W7fpJaVhM= - - CHROME_BIN=/usr/bin/google-chrome-stable +addons: + firefox: latest + chrome: stable From 018e7dff0988bb8ad3b743c21aaa1c2d34c40816 Mon Sep 17 00:00:00 2001 From: Eric Elliott Date: Wed, 7 Sep 2022 17:12:53 -0700 Subject: [PATCH 6/7] Update .travis.yml --- .travis.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a57158d..3502c942 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ language: node_js -node_js: "stable" - -dist: bionic - -before_install: - - stty cols 80 +node_js: + - 'lts/*' +install: + - npm install --legacy-peer-deps addons: firefox: latest From e18303f28d46862975670a36d2aaba34718f02f5 Mon Sep 17 00:00:00 2001 From: Eric Elliott Date: Wed, 7 Sep 2022 17:21:33 -0700 Subject: [PATCH 7/7] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3502c942..ae0c9e0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +dist: focal language: node_js node_js: - 'lts/*'