Skip to content

Commit

Permalink
fix(doctor): don't retry ping
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar authored and ruyadorno committed Mar 10, 2022
1 parent 0da5918 commit 1c182e1
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/commands/doctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Doctor extends BaseCommand {
const tracker = log.newItem('checkPing', 1)
tracker.info('checkPing', 'Pinging registry')
try {
await ping(this.npm.flatOptions)
await ping({ ...this.npm.flatOptions, retry: false })
return ''
} catch (er) {
if (/^E\d{3}$/.test(er.code || '')) {
Expand Down
58 changes: 58 additions & 0 deletions tap-snapshots/test/lib/commands/doctor.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,64 @@ Object {
}
`

exports[`test/lib/commands/doctor.js TAP bad proxy > logs 1`] = `
Object {
"error": Array [],
"info": Array [
Array [
"Running checkup",
],
Array [
"checkPing",
"Pinging registry",
],
Array [
"getLatestNpmVersion",
"Getting npm package information",
],
Array [
"getLatestNodejsVersion",
"Getting Node.js release information",
],
Array [
"getGitPath",
"Finding git in your PATH",
],
Array [
"verifyCachedFiles",
"Verifying the npm cache",
],
Array [
"verifyCachedFiles",
String(
Verification complete. Stats: {
"badContentCount": 0,
"reclaimedCount": 0,
"missingContent": 0,
"verifiedContent": 0
}
),
],
],
"warn": Array [],
}
`

exports[`test/lib/commands/doctor.js TAP bad proxy > output 1`] = `
Check Value Recommendation/Notes
npm ping not ok unsupported proxy protocol: 'ssh:'
npm -v not ok Error: unsupported proxy protocol: 'ssh:'
node -v not ok Error: unsupported proxy protocol: 'ssh:'
npm config get registry ok using default registry (https://registry.npmjs.org/)
which git ok /path/to/git
Perms check on cached files ok
Perms check on local node_modules ok
Perms check on global node_modules ok
Perms check on local bin folder ok
Perms check on global bin folder ok
Verify cache contents ok verified 0 tarballs
`

exports[`test/lib/commands/doctor.js TAP cacache badContent > corrupted cache content 1`] = `
Check Value Recommendation/Notes
npm ping ok
Expand Down
14 changes: 14 additions & 0 deletions test/lib/commands/doctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,17 @@ t.test('cacache missingContent', async t => {
t.matchSnapshot(joinedOutput(), 'missing content')
t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs')
})

t.test('bad proxy', async t => {
const { joinedOutput, logs, npm } = await loadMockNpm(t, {
mocks,
config: {
proxy: 'ssh://npmjs.org'
},
...dirs,
})
await t.rejects(npm.exec('doctor', []))
t.matchSnapshot(joinedOutput(), 'output')
t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs')
})

0 comments on commit 1c182e1

Please sign in to comment.