diff options
author | isaacs <i@izs.me> | 2012-06-29 05:47:31 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-06-29 05:48:11 +0400 |
commit | 419ffa05054fc3956ecad9fe8f124a70fcf935b6 (patch) | |
tree | bd79e6b3ef295de60292c26c231c17a5213512e8 | |
parent | 6b8d7d7072aa9c5ff12c59c9e68eda29b8a668b5 (diff) |
Make the fetch retry behavior configurable
-rw-r--r-- | doc/cli/config.md | 32 | ||||
-rw-r--r-- | lib/cache.js | 12 | ||||
-rw-r--r-- | lib/npm.js | 4 | ||||
-rw-r--r-- | lib/utils/config-defs.js | 9 |
4 files changed, 51 insertions, 6 deletions
diff --git a/doc/cli/config.md b/doc/cli/config.md index 917de2137..537af5ca0 100644 --- a/doc/cli/config.md +++ b/doc/cli/config.md @@ -308,6 +308,38 @@ Makes various commands more forceful. * skips cache when requesting from the registry. * prevents checks against clobbering non-npm files. +### fetch-retries + +* Default: 2 +* Type: Number + +The "retries" config for the `retry` module to use when fetching +packages from the registry. + +### fetch-retry-factor + +* Default: 10 +* Type: Number + +The "factor" config for the `retry` module to use when fetching +packages. + +### fetch-retry-mintimeout + +* Default: 10000 (10 seconds) +* Type: Number + +The "minTimeout" config for the `retry` module to use when fetching +packages. + +### fetch-retry-maxtimeout + +* Default: 60000 (1 minute) +* Type: Number + +The "maxTimeout" config for the `retry` module to use when fetching +packages. + ### git * Default: `"git"` diff --git a/lib/cache.js b/lib/cache.js index 269b19781..c6ca8b477 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -314,12 +314,12 @@ function addRemoteTarball (u, shasum, name, cb_) { if (er) return cb(er) // Tuned to spread 3 attempts over about a minute. // See formula at <https://github.com/tim-kos/node-retry>. - var operation = retry.operation({ - retries: 2, - factor: 10, - minTimeout: 10000, - maxTimeout: 60 * 1000 - }) + var operation = retry.operation + ( { retries: npm.config.get("fetch-retries") + , factor: npm.config.get("fetch-retry-factor") + , minTimeout: npm.config.get("fetch-retry-mintimeout") + , maxTimeout: npm.config.get("fetch-retry-maxtimeout") }) + operation.attempt(function (currentAttempt) { log.info("retry", "fetch attempt " + currentAttempt + " at " + (new Date()).toLocaleTimeString()) diff --git a/lib/npm.js b/lib/npm.js index f6460f9ae..589eb17fc 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -288,6 +288,10 @@ function load (npm, conf, cb) { , E404: npm.E404 , EPUBLISHCONFLICT: npm.EPUBLISHCONFLICT , log: log + , retries: npm.config.get("fetch-retries") + , retryFactor: npm.config.get("fetch-retry-factor") + , retryMinTimeout: npm.config.get("fetch-retry-mintimeout") + , retryMaxTimeout: npm.config.get("fetch-retry-maxtimeout") }) var umask = parseInt(conf.umask, 8) diff --git a/lib/utils/config-defs.js b/lib/utils/config-defs.js index f0982ad41..ee2c22f10 100644 --- a/lib/utils/config-defs.js +++ b/lib/utils/config-defs.js @@ -140,6 +140,11 @@ Object.defineProperty(exports, "defaults", {get: function () { , "engine-strict": false , force : false + , "fetch-retries": 2 + , "fetch-retry-factor": 10 + , "fetch-retry-mintimeout": 10000 + , "fetch-retry-maxtimeout": 60000 + , git: "git" , global : false @@ -226,6 +231,10 @@ exports.types = , editor : String , "engine-strict": Boolean , force : Boolean + , "fetch-retries": Number + , "fetch-retry-factor": Number + , "fetch-retry-mintimeout": Number + , "fetch-retry-maxtimeout": Number , git: String , global : Boolean , globalconfig : path |