Skip to content

Commit

Permalink
fix: friendlier errors for ERR_SOCKET_TIMEOUT
Browse files Browse the repository at this point in the history
PR-URL: #3498
Credit: @nlf
Close: #3498
Reviewed-by: @wraithgar
  • Loading branch information
nlf authored and wraithgar committed Jul 1, 2021
1 parent 339145f commit 4755b07
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/utils/error-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
23 changes: 23 additions & 0 deletions tap-snapshots/test/lib/utils/error-message.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
1 change: 1 addition & 0 deletions test/lib/utils/error-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ t.test('just simple messages', t => {
'ETOOMANYARGS',
'ETARGET',
'E403',
'ERR_SOCKET_TIMEOUT',
]
t.plan(codes.length)
codes.forEach(code => {
Expand Down

0 comments on commit 4755b07

Please sign in to comment.