eh-api-client
Advanced tools
Comparing version 0.23.0 to 0.24.0
@@ -12,3 +12,6 @@ var | ||
retryDelay: 100, | ||
retryStrategy: function(err) { | ||
retryStrategy: function(err, params) { | ||
if(params && params.method && params.method.toLowerCase() !== "get") { | ||
return false; | ||
} | ||
// only retry if got an ECONNRESET error | ||
@@ -15,0 +18,0 @@ return err.code === "ECONNRESET"; |
@@ -182,3 +182,3 @@ var | ||
if(err && retryOptions) { | ||
var strategySupported = retryOptions.retryStrategy(err); | ||
var strategySupported = retryOptions.retryStrategy(err, params); | ||
var maxAttemptsReached = numTry >= retryOptions.maxAttempts; | ||
@@ -185,0 +185,0 @@ if(!strategySupported) { |
{ | ||
"name": "eh-api-client", | ||
"version": "0.23.0", | ||
"version": "0.24.0", | ||
"description": "Node.js rest client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -106,2 +106,49 @@ var | ||
describe("POST use with retry if network error(Default behavior)", function() { | ||
var client = new Factory(url); | ||
var s; | ||
var requestsProcessed = 0; | ||
before(function(done) { | ||
createServer(function(_s) { | ||
s = _s; | ||
s.on("request", function(req, res) { | ||
requestsProcessed++; | ||
res.end("done"); | ||
}); | ||
s.timeout = SERVER_TIMEOUT; | ||
done(); | ||
}); | ||
}); | ||
after(function(done) { | ||
s.close(done); | ||
}); | ||
it("request shouldn't be retried", function(done) { | ||
var gotTryMoreThan1 = false; | ||
var gotReset; | ||
async.timesSeries(10, function(n, next) { | ||
client.post("/", {}, function(err, data, res) { | ||
if(err && err.message === "ECONNRESET") { | ||
gotReset = true; | ||
} | ||
else { | ||
data.should.equal("done"); | ||
if(res.retryInfo.try > 1) { | ||
gotTryMoreThan1 = true; | ||
} | ||
} | ||
setTimeout(next, SERVER_TIMEOUT - 5); | ||
}); | ||
}, function() { | ||
gotTryMoreThan1.should.equal(false); | ||
gotReset.should.equal(true); | ||
done(); | ||
}); | ||
}); | ||
it("count processed requests by server should match count of requests by client", function() { | ||
requestsProcessed.should.be.lessThan(10); | ||
}); | ||
}); | ||
describe("clients should share the factory's connection pool", function() { | ||
@@ -108,0 +155,0 @@ var factory = new Factory(url); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26074
878