diff --git a/lib/config/definitions.js b/lib/config/definitions.js index 982dfa05d5387923b9845092bafca17bf646cad4..42cab593e3120bd5203c8414ccc547e8238c8063 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -1703,6 +1703,11 @@ const options = [ name: 'hostRules', description: 'Host rules/configuration including credentials', type: 'array', + default: [ + { + timeout: 60000, + }, + ], stage: 'repository', cli: true, mergeable: true, @@ -1744,6 +1749,15 @@ const options = [ cli: false, env: false, }, + { + name: 'timeout', + description: 'timeout (in milliseconds) for queries to external endpoints', + type: 'integer', + stage: 'repository', + parent: 'hostRules', + cli: false, + env: false, + }, { name: 'prBodyDefinitions', description: 'Table column definitions for use in PR tables', diff --git a/lib/util/got/host-rules.js b/lib/util/got/host-rules.js index f37b12f6ab530d6d4b3bb145777b6b7b30f855ef..9aef144cab1b01191261382c66d288701edd7687 100644 --- a/lib/util/got/host-rules.js +++ b/lib/util/got/host-rules.js @@ -5,16 +5,13 @@ const hostRules = require('../host-rules'); // istanbul ignore next module.exports = got.create({ - options: { - // TODO: Move to configurable host rules - timeout: 60 * 1000, - }, + options: {}, handler: (options, next) => { const { hostType, ...opts } = options; if (!options.hostname) { return next(opts); } - const { username = '', password, token } = hostRules.find({ + const { username = '', password, token, timeout } = hostRules.find({ hostType, url: options.href, }); @@ -27,7 +24,9 @@ module.exports = got.create({ logger.debug('Applying Bearer authentication for host ' + opts.hostname); opts.token = token; } - // TODO: apply other options/headers + if (timeout) { + opts.timeout = timeout; + } return next(opts); }, }); diff --git a/renovate-schema.json b/renovate-schema.json index dd3c27075f972ce70fc11e0477f50cdeb744d7e8..6184d679e17c6185300a967784c93443765bd58d 100644 --- a/renovate-schema.json +++ b/renovate-schema.json @@ -1172,6 +1172,11 @@ "hostRules": { "description": "Host rules/configuration including credentials", "type": "array", + "default": [ + { + "timeout": 60000 + } + ], "items": { "allOf": [ { @@ -1192,6 +1197,10 @@ "baseUrl": { "description": "baseUrl for a host rule. e.g. \"https://api.github.com/\"", "type": "string" + }, + "timeout": { + "description": "timeout (in milliseconds) for queries to external endpoints", + "type": "integer" } } } diff --git a/website/docs/configuration-options.md b/website/docs/configuration-options.md index 26049d78f40f76d8a64017252a904b640029807c..26ffa3efc1356cc3bf239f05d062b63c6d61ee84 100644 --- a/website/docs/configuration-options.md +++ b/website/docs/configuration-options.md @@ -347,6 +347,16 @@ Renovate will match against all baseUrls. It does not do a "longest match" algor ### hostType +### timeout + +Use this figure to adjust the timeout for queries. The default is 60s, which is quite high. To adjust it down to 10s for all queries, do this: + +```json + "hostRules": [{ + "timeout": 10000, + }] +``` + ## ignoreDeprecated By default, Renovate won't update any packages to deprecated versions unless the package version was _already_ deprecated. The goal of this is to make sure you don't upgrade from a non-deprecated version to a deprecated one just because it's higher than the current version. If for some reason you wish to _force_ deprecated updates on Renovate, you can set `ignoreDeprecated` to `false`, but this is not recommended for most situations.