Gathering detailed insights and metrics for promise-retry
Gathering detailed insights and metrics for promise-retry
Gathering detailed insights and metrics for promise-retry
Gathering detailed insights and metrics for promise-retry
Retries a function that returns a promise, leveraging the power of the retry module.
npm install promise-retry
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.9
Supply Chain
97.2
Quality
79.7
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
317 Stars
59 Commits
26 Forks
6 Watchers
26 Branches
10 Contributors
Updated on Apr 08, 2025
Latest Version
2.0.1
Package Id
promise-retry@2.0.1
Size
4.00 kB
NPM Version
6.14.1
Node Version
12.16.1
Published on
Jun 14, 2020
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
Retries a function that returns a promise, leveraging the power of the retry module to the promises world.
There's already some modules that are able to retry functions that return promises but they were rather difficult to use or do not offer an easy way to do conditional retries.
$ npm install promise-retry
Calls fn
until the returned promise ends up fulfilled or rejected with an error different than
a retry
error.
The options
argument is an object which maps to the retry module options:
retries
: The maximum amount of times to retry the operation. Default is 10
.factor
: The exponential factor to use. Default is 2
.minTimeout
: The number of milliseconds before starting the first retry. Default is 1000
.maxTimeout
: The maximum number of milliseconds between two retries. Default is Infinity
.randomize
: Randomizes the timeouts by multiplying with a factor between 1
to 2
. Default is false
.The fn
function will receive a retry
function as its first argument that should be called with an error whenever you want to retry fn
. The retry
function will always throw an error.
If there are retries left, it will throw a special retry
error that will be handled internally to call fn
again.
If there are no retries left, it will throw the actual error passed to it.
If you prefer, you can pass the options first using the alternative function signature promiseRetry([options], fn)
.
1var promiseRetry = require('promise-retry'); 2 3// Simple example 4promiseRetry(function (retry, number) { 5 console.log('attempt number', number); 6 7 return doSomething() 8 .catch(retry); 9}) 10.then(function (value) { 11 // .. 12}, function (err) { 13 // .. 14}); 15 16// Conditional example 17promiseRetry(function (retry, number) { 18 console.log('attempt number', number); 19 20 return doSomething() 21 .catch(function (err) { 22 if (err.code === 'ETIMEDOUT') { 23 retry(err); 24 } 25 26 throw err; 27 }); 28}) 29.then(function (value) { 30 // .. 31}, function (err) { 32 // .. 33});
$ npm test
Released under the MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 7/29 approved changesets -- score normalized to 2
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
12 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More