Socket
Socket
Sign inDemoInstall

eh-api-client

Package Overview
Dependencies
49
Maintainers
2
Versions
97
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.23.0 to 0.24.0

5

index.js

@@ -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";

2

lib/client.js

@@ -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);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc