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

PR-URL: #1870
Credit: @isaacs
Close: #1870
Reviewed-by: @nlf
  • Loading branch information
isaacs authored and nlf committed Sep 29, 2020
1 parent e225ddc commit 2469ae5
Show file tree
Hide file tree
Showing 6 changed files with 19 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
6 changes: 6 additions & 0 deletions tap-snapshots/test-lib-utils-config.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Object {
"fetch-retry-factor": 10,
"fetch-retry-maxtimeout": 60000,
"fetch-retry-mintimeout": 10000,
"fetch-timeout": 300000,
"force": false,
"format-package-lock": true,
"fund": true,
Expand Down Expand Up @@ -339,6 +340,7 @@ Object {
"fetch-retry-factor": "{Number TYPE}",
"fetch-retry-maxtimeout": "{Number TYPE}",
"fetch-retry-mintimeout": "{Number TYPE}",
"fetch-timeout": "{Number TYPE}",
"force": "{Boolean TYPE}",
"format-package-lock": "{Boolean TYPE}",
"fund": "{Boolean TYPE}",
Expand Down Expand Up @@ -554,6 +556,7 @@ Object {
"fetch-retry-factor": 10,
"fetch-retry-maxtimeout": 60000,
"fetch-retry-mintimeout": 10000,
"fetch-timeout": 300000,
"force": false,
"format-package-lock": true,
"fund": true,
Expand Down Expand Up @@ -851,6 +854,7 @@ Object {
"fetch-retry-factor": "{Number TYPE}",
"fetch-retry-maxtimeout": "{Number TYPE}",
"fetch-retry-mintimeout": "{Number TYPE}",
"fetch-timeout": "{Number TYPE}",
"force": "{Boolean TYPE}",
"format-package-lock": "{Boolean TYPE}",
"fund": "{Boolean TYPE}",
Expand Down Expand Up @@ -1066,6 +1070,7 @@ Object {
"fetch-retry-factor": 10,
"fetch-retry-maxtimeout": 60000,
"fetch-retry-mintimeout": 10000,
"fetch-timeout": 300000,
"force": false,
"format-package-lock": true,
"fund": true,
Expand Down Expand Up @@ -1363,6 +1368,7 @@ Object {
"fetch-retry-factor": "{Number TYPE}",
"fetch-retry-maxtimeout": "{Number TYPE}",
"fetch-retry-mintimeout": "{Number TYPE}",
"fetch-timeout": "{Number TYPE}",
"force": "{Boolean TYPE}",
"format-package-lock": "{Boolean TYPE}",
"fund": "{Boolean TYPE}",
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 2469ae5

Please sign in to comment.