
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Quickly and easily wrap functions to make them retry when they fail.
$ npm install retryify
// create a new retryify wrapper with some options set.
const retryify = require('retryify')({
retries: 5,
timeout: 1000,
factor: 2,
errors: [RequestError, StatusCodeError],
log: function(msg) { console.log(msg); },
});
// promisified request library
const request = require('request-promise');
// get will now retry each time it catches a RequestError or a
// StatusCodeError, it retries 5 times, or the request finally resolves
// successfully.
const get = retryify(function(url) {
return request(url);
});
// or, add some custom options for this specific function
const post = retryify({
retries: 10
}, function(url, data) {
return request({
uri: url,
method: 'POST',
});
});
// send the request, but retry if it fails.
get('http://google.com')
.then(...)
.catch(...);
functionRetry module setup function. Takes an options object that configures the default retry options.
Kind: global function
Returns: function - retryWrapper A decorator function that wraps a
a function to turn it into a retry-enabled function.
Throws:
| Param | Type | Default | Description |
|---|---|---|---|
| [options] | Options | {} | Optional configuration object |
functionretryify function decorator. Allows configuration on a function by function basis.
Kind: inner method of retryify
Returns: function - The wrapped function.
| Param | Type | Description |
|---|---|---|
| [innerOptions] | Options | Optional configuration object. Same format as above. |
| fn | function | The function to wrap. Will retry the function if any matching errors are caught. |
ObjectKind: global typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [options.retries] | Number | 3 | Number of times to retry a wrapped function |
| [options.initialDelay] | Number | 0 | Amount of time (ms) to wait before any function attempts |
| [options.timeout] | Number | 300 | Amount of time (ms) to wait between retries |
| [options.factor] | Number | 2 | The exponential factor to scale the timeout by every retry iteration. For example: with a factor of 2 and a timeout of 100 ms, the first retry will fire after 100 ms, the second after 200 ms, the third after 400 ms, etc.... The formula used to calculate the delay between each retry: timeout * Math.pow(factor, attempts) |
| [options.shouldRetry] | function | () => true | Invoked with the thrown error, retryify will retry if this method returns true. |
| [options.log] | function | Logging function that takes a message as |
FAQs
Wrap a function to retry on specific errors
The npm package retryify receives a total of 321 weekly downloads. As such, retryify popularity was classified as not popular.
We found that retryify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.