Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
A retry library for node.js.
Rerun supports promises and request.js, as you will see, the API is pretty simple.
The options and their defaults for rerun library are:
{
retries: 3
retryTimeout: 50
retryFactor: 1
}
retries
- How many times to retry before failing.retryTimeout
- The initial time to wait (in milliseconds) before each retry.retryFactor
- The multiplier after each fail to multiply retryTimeout
with.Rerun use with request is the same as with request itself, but with promises.
var request = require('rerun').request;
var promise = request({method:'POST', url: 'http://localhost/test', retries: 2, retryTimeout: 10, retryFactor: 2});
Rerun with promises is easy too, all you need is to call the library with the function you want to retry, and if it fails, the library will try again.
Notice that if you don't want the library to retry, you can throw require('rerun').RejectError
.
var retry = require('rerun').promise;
var promise = retry(function () { doSomething(); }, { retries: 2, retryTimeout: 10, retryFactor: 2 });
Want to proxy all methods of an object with rerun functionality? Piece of cake! To proxy all methods:
var object = { foo: function() {} }
var retry = require('rerun').proxy;
var proxy = retry.all(object, { retries: 2, retryTimeout: 10, retryFactor: 2 })
var promise = proxy.foo()
To proxy only some methods:
var object = { foo: function() {}, bar: function() {}}
var retry = require('rerun').proxy;
var proxy = retry.some(object, ['foo'], { retries: 2, retryTimeout: 10, retryFactor: 2 })
var promise = proxy.foo()
Notice that proxied functions are expected to return a promise.
FAQs
A retry library for node.js
The npm package rerun receives a total of 25 weekly downloads. As such, rerun popularity was classified as not popular.
We found that rerun demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.