From 1d474e409fc893dd5b94b2dc1a0bf5b758577a14 Mon Sep 17 00:00:00 2001 From: Michael Kriese <michael.kriese@visualon.de> Date: Fri, 10 May 2019 11:54:01 +0200 Subject: [PATCH] feat: add 60s timeout to all requests (#3641) --- lib/datasource/npm/get.js | 2 ++ lib/manager/bazel/update.js | 6 +++++- lib/manager/gradle-wrapper/update.js | 5 ++++- lib/manager/homebrew/update.js | 6 +++++- lib/platform/bitbucket-server/bb-got-wrapper.js | 2 ++ lib/platform/bitbucket/bb-got-wrapper.js | 2 ++ lib/platform/github/gh-got-wrapper.js | 2 ++ lib/platform/gitlab/gl-got-wrapper.js | 2 ++ lib/util/got/host-rules.js | 5 ++++- 9 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/datasource/npm/get.js b/lib/datasource/npm/get.js index 426c9b6dda..c2de383486 100644 --- a/lib/datasource/npm/get.js +++ b/lib/datasource/npm/get.js @@ -102,6 +102,8 @@ async function getDependency(name) { 'EAI_AGAIN', ], }, + // TODO: Move to configurable host rules + timeout: 60 * 1000, headers, }); const res = raw.body; diff --git a/lib/manager/bazel/update.js b/lib/manager/bazel/update.js index 04977c9168..28093dc779 100644 --- a/lib/manager/bazel/update.js +++ b/lib/manager/bazel/update.js @@ -35,7 +35,11 @@ async function updateDependency(fileContent, upgrade) { newUrl = `https://github.com/${upgrade.repo}/releases/download/${ upgrade.newValue }/${shortRepo}-${upgrade.newValue}.tar.gz`; - file = (await got(newUrl, { encoding: null })).body; + file = (await got(newUrl, { + encoding: null, + // TODO: Move to configurable host rules, or use utils/got + timeout: 60 * 1000, + })).body; } catch (err) { logger.debug( 'Failed to download release download - trying archive instead' diff --git a/lib/manager/gradle-wrapper/update.js b/lib/manager/gradle-wrapper/update.js index 491f39fc33..77a42696eb 100644 --- a/lib/manager/gradle-wrapper/update.js +++ b/lib/manager/gradle-wrapper/update.js @@ -38,7 +38,10 @@ function replaceType(url) { async function getChecksum(url) { try { - const response = await got(url, {}); + const response = await got(url, { + // TODO: Move to configurable host rules, or use utils/got + timeout: 60 * 1000, + }); return response.body; } catch (err) { if (err.statusCode === 404 || err.code === 'ENOTFOUND') { diff --git a/lib/manager/homebrew/update.js b/lib/manager/homebrew/update.js index 201823405e..b5519e6e76 100644 --- a/lib/manager/homebrew/update.js +++ b/lib/manager/homebrew/update.js @@ -34,7 +34,11 @@ async function updateDependency(content, upgrade) { }/releases/download/${upgrade.newValue}/${upgrade.repoName}-${coerce( upgrade.newValue )}.tar.gz`; - file = (await got(newUrl, { encoding: null })).body; + file = (await got(newUrl, { + encoding: null, + // TODO: Move to configurable host rules, or use utils/got + timeout: 60 * 1000, + })).body; } catch (errOuter) { logger.debug( `Failed to download release download for ${ diff --git a/lib/platform/bitbucket-server/bb-got-wrapper.js b/lib/platform/bitbucket-server/bb-got-wrapper.js index 9c6456fe15..5aa97dcc60 100644 --- a/lib/platform/bitbucket-server/bb-got-wrapper.js +++ b/lib/platform/bitbucket-server/bb-got-wrapper.js @@ -9,6 +9,8 @@ const platform = 'bitbucket-server'; async function get(path, options) { const { host } = URL.parse(path); const opts = { + // TODO: Move to configurable host rules, or use utils/got + timeout: 60 * 1000, json: true, basic: false, ...hostRules.find({ platform, host }), diff --git a/lib/platform/bitbucket/bb-got-wrapper.js b/lib/platform/bitbucket/bb-got-wrapper.js index 901e52e9fa..8197f92822 100644 --- a/lib/platform/bitbucket/bb-got-wrapper.js +++ b/lib/platform/bitbucket/bb-got-wrapper.js @@ -7,6 +7,8 @@ let cache = {}; async function get(path, options) { const { host } = URL.parse(path); const opts = { + // TODO: Move to configurable host rules, or use utils/got + timeout: 60 * 1000, json: true, basic: false, ...hostRules.find({ platform: 'bitbucket', host }), diff --git a/lib/platform/github/gh-got-wrapper.js b/lib/platform/github/gh-got-wrapper.js index 60ba586c97..5022269783 100644 --- a/lib/platform/github/gh-got-wrapper.js +++ b/lib/platform/github/gh-got-wrapper.js @@ -13,6 +13,8 @@ let stats = {}; async function get(path, options, retries = 5) { const { host } = URL.parse(path); const opts = { + // TODO: Move to configurable host rules, or use utils/got + timeout: 60 * 1000, ...hostRules.find({ platform: 'github', host }), ...options, }; diff --git a/lib/platform/gitlab/gl-got-wrapper.js b/lib/platform/gitlab/gl-got-wrapper.js index b94465521b..c6d159639d 100644 --- a/lib/platform/gitlab/gl-got-wrapper.js +++ b/lib/platform/gitlab/gl-got-wrapper.js @@ -10,6 +10,8 @@ let cache = {}; async function get(path, options, retries = 5) { const { host } = URL.parse(path); const opts = { + // TODO: Move to configurable host rules, or use utils/got + timeout: 60 * 1000, ...hostRules.find({ platform: 'gitlab', host }), ...options, }; diff --git a/lib/util/got/host-rules.js b/lib/util/got/host-rules.js index e9c1520412..0586916e70 100644 --- a/lib/util/got/host-rules.js +++ b/lib/util/got/host-rules.js @@ -5,7 +5,10 @@ const hostRules = require('../host-rules'); // istanbul ignore next module.exports = got.create({ - options: {}, + options: { + // TODO: Move to configurable host rules + timeout: 60 * 1000, + }, handler: (options, next) => { const { platform, ...opts } = options; if (!options.hostname) { -- GitLab