eh-api-client
Advanced tools
Comparing version 0.32.0 to 0.33.0
@@ -215,4 +215,5 @@ var | ||
Client.prototype._tryRequest = function(params, numTry, cb) { | ||
Client.prototype._tryRequest = function(params, tryErrorHistory, cb) { | ||
var startTime = new Date().getTime(); | ||
var numTry = tryErrorHistory.length + 1; | ||
debuglog("Try(" + numTry + "): ", params); | ||
@@ -248,3 +249,4 @@ var retryOptions = this._factory.retryOptions; | ||
try: numTry, | ||
strategySupported: strategySupported | ||
strategySupported: strategySupported, | ||
tryErrorHistory: tryErrorHistory | ||
}; | ||
@@ -256,6 +258,6 @@ var debugParams = _.clone(params); | ||
} | ||
numTry++; | ||
tryErrorHistory.push(err); | ||
// retry | ||
return setTimeout(function() { | ||
self._tryRequest(params, numTry, cb); | ||
self._tryRequest(params, tryErrorHistory, cb); | ||
}, retryOptions.retryDelay); | ||
@@ -266,3 +268,4 @@ } | ||
res.retryInfo = { | ||
try: numTry | ||
try: numTry, | ||
tryErrorHistory: tryErrorHistory | ||
}; | ||
@@ -285,3 +288,3 @@ } | ||
}).then(function() { | ||
return self._tryRequest(params, 1, cb); | ||
return self._tryRequest(params, [], cb); | ||
}); | ||
@@ -288,0 +291,0 @@ }; |
{ | ||
"name": "eh-api-client", | ||
"version": "0.32.0", | ||
"version": "0.33.0", | ||
"description": "Node.js rest client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -88,2 +88,6 @@ var | ||
err.retryInfo.strategySupported.should.equal(true); | ||
err.retryInfo.tryErrorHistory.length.should.equal(err.retryInfo.try - 1); | ||
err.retryInfo.tryErrorHistory.forEach(function(err) { | ||
err.message.should.equal("ETIMEDOUT"); | ||
}); | ||
done(); | ||
@@ -90,0 +94,0 @@ }); |
79950
1927