Skip to content

Commit

Permalink
feat(host-rules): configurable timeout
Browse files Browse the repository at this point in the history
Closes #3640
  • Loading branch information
rarkins committed May 25, 2019
1 parent bc076c3 commit c9bfccf
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
14 changes: 14 additions & 0 deletions lib/config/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down
11 changes: 5 additions & 6 deletions lib/util/got/host-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand All @@ -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);
},
});
9 changes: 9 additions & 0 deletions renovate-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,11 @@
"hostRules": {
"description": "Host rules/configuration including credentials",
"type": "array",
"default": [
{
"timeout": 60000
}
],
"items": {
"allOf": [
{
Expand All @@ -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"
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions website/docs/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c9bfccf

Please sign in to comment.