From a167840ecadf1187a7fbb05100037831fa2f1179 Mon Sep 17 00:00:00 2001 From: Christopher Sidebottom Date: Thu, 14 Aug 2014 11:38:42 +0100 Subject: [PATCH] Stretch request timeout in line with retry timeout --- lib/Fetcher.js | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Fetcher.js b/lib/Fetcher.js index 2695d73..6c74c76 100755 --- a/lib/Fetcher.js +++ b/lib/Fetcher.js @@ -14,7 +14,7 @@ function Fetcher(config) { api_key: config.apiKey }; requestOptions = { - timeout: 1000 + timeout: 5000 }; retryOptions = { retries: 3, @@ -49,6 +49,7 @@ Fetcher.prototype._request = function (feedName, params) { var defer = Q.defer(), that = this, operation = retry.operation(retryOptions), + timeouts = retry.timeouts(retryOptions), params = u.extend({}, this.defaultRequestParams, params), url = this.config.iblUrl + feedName + '.json?' + qs.stringify(params), requestOptions = u.extend({}, this.requestOptions, {url:url}); @@ -57,6 +58,8 @@ Fetcher.prototype._request = function (feedName, params) { if (cached === false) { operation.attempt(function(currentAttempt) { + requestOptions.timeout = timeouts[currentAttempt-1]; + that.request(requestOptions, function (err, response, body) { if (operation.retry(err)) { console.log("[INFO] Retrying ", feedName); diff --git a/package.json b/package.json index 64f3622..00a851d 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fixturator", - "version": "0.1.11", + "version": "0.1.12", "description": "", "main": "index.js", "repository": {