fix: use 30s default for timeout as per README #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What / Why
The README specifies that the default for the timeout option is 30 seconds, but in reality no default is set. This seems to result in the timeout depending on the OS's default TCP socket timeouts which can be very long.
Background
I've been experiencing
$ npm install
occasionally hanging for long periods of time in docker image builds. When enabling--verbose
I see mostnpm http fetch *
lines taking < 200ms but occasionally requests take more like 10 seconds, and less commonly hang for 5 minutes or so.I assumed this was due to too much exponential backoff from the
retry
module, but in looking into this I noticed that npm doesn't document a timeout option (although setting atimeout
in npm config does work), or explicitly specify a timeout when using this module, and this module's specified default of 30 seconds is not actually used in practice – no default is currently defined.The default exponential backoff from the
fetch-retry-*
settings imply a 10s pause after the first failure, then a 60s pause after the second failure, followed by a final attempt. This contributes to some of the time spent hanging, but not all of it. The long timeouts on each of the 3 possible failing fetches mean it can take many minutes for a fetch to actually fail.With the 30s default timeout, a fetch should take at most 2m40s to fail (30 + 10 + 30 + 60 + 30).
References
npm install
in docker npm#8836