From 06cb50cf10cae47a36a6ff8724c62fbf7f98e701 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Sat, 25 May 2019 19:48:05 +0200 Subject: [PATCH] fix: Revert "fix: Revert "feat(host-rules): configurable timeout"" This reverts commit e3937fa89a0548ada0e2e726d950672326bf5702. --- lib/config/definitions.js | 14 ++++++++++++++ lib/util/got/host-rules.js | 11 +++++------ renovate-schema.json | 9 +++++++++ website/docs/configuration-options.md | 10 ++++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lib/config/definitions.js b/lib/config/definitions.js index 982dfa05d5..42cab593e3 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 f37b12f6ab..9aef144cab 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 dd3c27075f..6184d679e1 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 26049d78f4..26ffa3efc1 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. -- GitLab