Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rerun

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rerun - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

2

package.json
{
"name": "rerun",
"description": "A retry library for node.js",
"version": "1.0.1",
"version": "1.1.0",
"author": "BigPanda <noam@bigpanda.io>",

@@ -6,0 +6,0 @@ "repository": {

@@ -11,2 +11,3 @@ var Q = require('q');

var userRejectError = options.rejectError || RejectError;
var randomizeRetry = options.retryRandom || false;

@@ -21,3 +22,4 @@ function _succeed(returned) {

} else {
Q.delay(timeout).then(function () { return toRetry() }).then(_succeed, _failed);
var timeToWait = randomizeRetry ? Math.random() * (timeout / 2) + (timeout / 2) : timeout;
Q.delay(timeToWait).then(function () { return toRetry() }).then(_succeed, _failed);
timeout *= factor;

@@ -24,0 +26,0 @@ }

@@ -118,2 +118,24 @@ var chai = require('chai');

});
it('should randomize time', function (done) {
var id = { complicated: 'id' };
var data = [
{ foo: 'bar' }
];
var array = [
{ id: id, data: data }
];
nock('http://localhost:3027').post('/test', JSON.stringify({ objects: array })).times(1).reply(401);
var scope = nock('http://localhost:3027').post('/test', JSON.stringify({ objects: array })).reply(200);
var promise = request({ url: 'http://localhost:3027/test', json: { objects: array }, retries: 2, retryFactor: 2, retryTimeout: 200, retryRandom: true, method: 'POST' });
var timeBefore = new Date().getTime();
promise.then(function () {
expect(new Date().getTime() - timeBefore).to.lte(200).and.to.gte(100);
scope.done();
done();
}, function (err) {
done(err);
});
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc