0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-17 23:45:29 -05:00

Merge pull request #18 from iambrandonn/master

Adding a configurable timeout for each uplink
This commit is contained in:
Alex Kocharin 2013-12-05 09:31:35 -08:00
commit ff52b00a7c
2 changed files with 8 additions and 0 deletions

View file

@ -12,6 +12,10 @@ uplinks:
npmjs:
url: https://registry.npmjs.org/
# amount of time to wait for repository to respond before giving up
# and use the local cached copy
timeout: 3000
# maximum time (in seconds) in which data is considered up to date
#
# default is 2 minutes, so server won't request the same data from

View file

@ -32,6 +32,9 @@ function Storage(config, mainconfig) {
_setupProxy.call(this, this.url.hostname, config, mainconfig, this.url.protocol === 'https:')
this.config.url = this.config.url.replace(/\/$/, '')
if (isNaN(parseFloat(this.config.timeout)) || !isFinite(this.config.timeout)) {
this.config.timeout = 5000
}
return this
}
@ -105,6 +108,7 @@ Storage.prototype.request = function(options, cb) {
body: json,
ca: this.ca,
proxy: this.proxy,
timeout: this.config.timeout
}, function(err, res, body) {
var error
if (!err) {