Skip to content

Commit

Permalink
Add 'fetch-timeout' config
Browse files Browse the repository at this point in the history
This gets passed down to dependencies as 'timeout', so that the HTTP
request libraries will all get the right value.

Fix: #1780
  • Loading branch information
isaacs committed Sep 28, 2020
1 parent 9bc6966 commit 87fbc73
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/content/using-npm/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,13 @@ packages.
The "maxTimeout" config for the `retry` module to use when fetching
packages.

#### fetch-timeout

* Default: 300000 (5 minutes)
* Type: Number

The maximum amount of time to wait for HTTP requests to complete.

#### fund

* Default: true
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const defaults = {
'fetch-retry-factor': 10,
'fetch-retry-mintimeout': 10000,
'fetch-retry-maxtimeout': 60000,
'fetch-timeout': 5 * 60 * 1000,

git: 'git',
'git-tag-version': true,
Expand Down Expand Up @@ -221,6 +222,7 @@ const types = {
'fetch-retry-factor': Number,
'fetch-retry-mintimeout': Number,
'fetch-retry-maxtimeout': Number,
'fetch-timeout': Number,
git: String,
'git-tag-version': Boolean,
'commit-hooks': Boolean,
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ const flatOptions = npm => npm.flatOptions || Object.freeze({
minTimeout: npm.config.get('fetch-retry-mintimeout')
},

timeout: npm.config.get('fetch-timeout'),

force: npm.config.get('force'),

formatPackageLock: npm.config.get('format-package-lock'),
Expand Down
1 change: 1 addition & 0 deletions tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Object {
"strictSSL": "strict-ssl",
"tag": "tag",
"tagVersionPrefix": "tag-version-prefix",
"timeout": "fetch-timeout",
"tmp": "/tmp",
"umask": 18,
"unicode": undefined,
Expand Down
1 change: 1 addition & 0 deletions test/lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class MockConfig {
'fetch-retry-factor': 'fetch-retry-factor',
'fetch-retry-mintimeout': 'fetch-retry-mintimeout',
'fetch-retry-maxtimeout': 'fetch-retry-maxtimeout',
'fetch-timeout': 'fetch-timeout',
force: 'force',
'format-package-lock': 'format-package-lock',
fund: 'fund',
Expand Down

0 comments on commit 87fbc73

Please sign in to comment.