cli
cli copied to clipboard
[BUG] npm doesn't log intermediate fetch retry failures
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] I am using the latest npm
Current Behavior
npm retries idempotent read requests to the registry (ref). But it doesn't log the intermediate errors, regardless of loglevel.
Logging every http response or network failure would aid investigations. For example, if npm install
is slow, it would useful to know why initial attempts failed, and how long individual http requests took.
Expected Behavior
Every http response or network failure is logged when the loglevel is verbose
or higher.
Steps To Reproduce
Intentionally using https://httpbin.org for fault injection. When the supplied package name, 503
, is appended to https://httpbin.org/status, that causes our "registry" to return a 503 status code, a retryable response.
-
npm view 503 --loglevel silly --registry=https://httpbin.org/status --fetch-retries=2
(2 retries is the default) - The command will fail with
error 503 SERVICE UNAVAILABLE
. That's expected. - Inspect the log output. You'll see there were three attempts to retrieve package details, but only the final
503
http response is recorded. Log snippet:
31 silly logfile done cleaning log files
32 http fetch GET 503 https://httpbin.org/status/503 80700ms attempt #3 (cache skip)
33 timing command:view Completed in 80705ms
34 verbose stack HttpErrorGeneral: 503 SERVICE UNAVAILABLE - GET https://httpbin.org/status/503
Environment
- npm:
[email protected]
- Node.js:
[email protected]
- OS Name: macOS 14.4.1
- System Model Name: MacBook Air 15"
- npm config:
; "user" config from /Users/hashtagchris/.npmrc
@npm:registry = "https://npm.pkg.github.com"
//npm.pkg.github.com/:_authToken = (protected)
//registry-sandbox.npm.red/:_authToken = (protected)
//registry.npmjs.org/:_authToken = (protected)
logs-max = 1000
; node bin location = /Users/hashtagchris/.nvm/versions/node/v20.12.2/bin/node
; node version = v20.12.2
; npm local prefix = /Users/hashtagchris/r/npm
; npm version = 10.5.2
; cwd = /Users/hashtagchris/r/npm
; HOME = /Users/hashtagchris
; Run `npm config ls -l` to show all defaults.