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.
retry-machine
Advanced tools
A simple and configurable utility for retrying promises with exponential backoff.
npm install retry-machine
or
yarn add retry-machine
retry-machine
provides a flexible way to handle retries in your promises
with support for exponential backoff and optional logging.
import { retry } from 'retry-machine';
async function run(attempt) {
console.log(`Attempt ${attempt}`);
if (Math.random() < 0.7) {
throw new Error('Random failure');
}
return 'Success!';
}
async function failure(error, attemptsRemaining) {
console.error(e);
}
const runner = retry({ max: 5, delay: 1000, factor: 2, maxDelay: 5000 }, failure);
await runner(run, 1);
max
: The maximum number of attempts to retry the function. Default is 3.delay
: The initial delay between attempts, in milliseconds. Default is 1000.factor
: The exponential backoff factor. Default is 1.logger
: Optional logger to log failures and retry attempts.maxDelay
: The maximum delay between attempts, in milliseconds. Default is 30000 (30 seconds).FAQs
Retry Promises
The npm package retry-machine receives a total of 356 weekly downloads. As such, retry-machine popularity was classified as not popular.
We found that retry-machine demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.