diff options
author | nlf <quitlahok@gmail.com> | 2021-07-02 01:08:52 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-07-02 01:21:35 +0300 |
commit | 4755b072877f547585cb0e2562261b2c87e2ff0b (patch) | |
tree | 4172831b7c190be700e2335c56fb95a8ac84d6f7 | |
parent | 339145f64f82d540dbc72ef97b54ae20c34315dd (diff) |
fix: friendlier errors for ERR_SOCKET_TIMEOUT
PR-URL: https://github.com/npm/cli/pull/3498
Credit: @nlf
Close: #3498
Reviewed-by: @wraithgar
-rw-r--r-- | lib/utils/error-message.js | 1 | ||||
-rw-r--r-- | tap-snapshots/test/lib/utils/error-message.js.test.cjs | 23 | ||||
-rw-r--r-- | test/lib/utils/error-message.js | 1 |
3 files changed, 25 insertions, 0 deletions
diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js index 125cdf8c5..3b590f712 100644 --- a/lib/utils/error-message.js +++ b/lib/utils/error-message.js @@ -269,6 +269,7 @@ module.exports = (er, npm) => { case 'ECONNRESET': case 'ENOTFOUND': case 'ETIMEDOUT': + case 'ERR_SOCKET_TIMEOUT': case 'EAI_FAIL': short.push(['network', er.message]) detail.push([ diff --git a/tap-snapshots/test/lib/utils/error-message.js.test.cjs b/tap-snapshots/test/lib/utils/error-message.js.test.cjs index 7b02dbd9a..5b6e3c85a 100644 --- a/tap-snapshots/test/lib/utils/error-message.js.test.cjs +++ b/tap-snapshots/test/lib/utils/error-message.js.test.cjs @@ -1289,6 +1289,29 @@ Object { } ` +exports[`test/lib/utils/error-message.js TAP just simple messages > must match snapshot 23`] = ` +Object { + "detail": Array [ + Array [ + "network", + String( + This is a problem related to network connectivity. + In most cases you are behind a proxy or have bad network settings. + + If you are behind a proxy, please make sure that the + 'proxy' config is set properly. See: 'npm help config' + ), + ], + ], + "summary": Array [ + Array [ + "network", + "foo", + ], + ], +} +` + exports[`test/lib/utils/error-message.js TAP just simple messages > must match snapshot 3`] = ` Object { "detail": Array [ diff --git a/test/lib/utils/error-message.js b/test/lib/utils/error-message.js index 4f94645a4..3fdfb8cc2 100644 --- a/test/lib/utils/error-message.js +++ b/test/lib/utils/error-message.js @@ -97,6 +97,7 @@ t.test('just simple messages', t => { 'ETOOMANYARGS', 'ETARGET', 'E403', + 'ERR_SOCKET_TIMEOUT', ] t.plan(codes.length) codes.forEach(code => { |