Gathering detailed insights and metrics for async-await-retry
Gathering detailed insights and metrics for async-await-retry
Gathering detailed insights and metrics for async-await-retry
Gathering detailed insights and metrics for async-await-retry
npm install async-await-retry
Typescript
Module System
Min. Node Version
Node Version
NPM Version
80.1
Supply Chain
100
Quality
75.8
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
24 Stars
59 Commits
1 Forks
2 Watchers
3 Branches
4 Contributors
Updated on Mar 27, 2025
Latest Version
2.1.0
Package Id
async-await-retry@2.1.0
Unpacked Size
11.68 kB
Size
4.01 kB
File Count
5
NPM Version
8.5.1
Node Version
16.10.0
Published on
Nov 21, 2023
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
Minimalist, efficient and performance focused retry system. Basically it helps developer to retry a function with a specific interval, exponential factor etc.
No dependency.
/!\ This module use async/await syntax, this is why you must have node 7.6+.
Supported and tested : >= 7.6
Version | Supported | Tested |
---|---|---|
20.x | yes | yes |
18.x | yes | yes |
16.x | yes | yes |
14.x | yes | yes |
12.x | no | yes |
10.x | no | yes |
9.x | no | yes |
8.x | no | yes |
>= 7.6 | no | yes |
1$ npm install async-await-retry --save
1const retry = require('async-await-retry'); 2 3const func = async () => {return new Promise((resolve) => resolve('OK'))}; 4 5try { 6 const res = await retry(func) 7} catch (err) { 8 console.log('The function execution failed !') 9}
1const retry = require('async-await-retry'); 2 3const func = () => {...}; 4 5try { 6 const res = await retry(func) 7 console.log(res) // output : OK 8} catch (err) { 9 console.log('The function execution failed !') 10}
1const retry = require('async-await-retry'); 2 3try { 4 const res = await retry(async () => { 5 return new Promise((resolve) => resolve('OK')) 6 }) 7 8 console.log(res) // output : OK 9} catch (err) { 10 console.log('The function execution failed !') 11}
1const retry = require('async-await-retry'); 2 3try { 4 const res = await retry((arg1, cb) => { 5 .... 6 cb(err, data); // send err as first argument 7 }, ["arg1"], {isCb: true}); 8} catch (err) { 9 console.log('The function execution failed !') 10}
## retry(function, [args], [config])
function
: function to retry in case of errorargs
: your function's parameters in case you don't use callback styleconfig
: an object containing all retry process optionsOption | description | Default value |
---|---|---|
retriesMax | Maximum number of retries | 3 |
interval | Delay in ms between two tentatives | 0 |
exponential | Will the interval increase exponentially ? | true |
maxBackoff | Maximum delay before to retry (with exponential) | 30s |
factor | The exponential factor to use | 2 |
jitter | Random jitter in ms to add to the interval | 0 |
isCb | Old callback function style ? | false |
onAttemptFail | User's callback to manage retry system | default fallback |
An example of custom options :
1const retry = require('async-await-retry'); 2 3try { 4 const res = await retry(async () => { 5 return new Promise((resolve) => resolve('OK')) 6 }, null, {retriesMax: 4, interval: 100, exponential: true, factor: 3, jitter: 100}) 7 8 console.log(res) // output : OK 9} catch (err) { 10 console.log('The function execution failed !') 11}
This method can be used to manage, by yourself, the retry system. It's called when an error occurred and before to retry. This method can have three behaviors:
1const retry = require('async-await-retry'); 2 3try { 4 const res = await retry(MyfuncToRetry, null, { 5 onAttemptFail: (data) => { 6 // do some stuff here, like logging errors 7 } 8 }); 9} catch (err) { 10 console.log('The function execution failed !') 11}
The data argument is an object that can be described like this:
Property | description |
---|---|
error | The current error object |
currentRetry | The current retry value |
retriesMax | Maximum number of retries |
interval | Delay in ms between two tentatives |
exponential | Will the interval increase exponentially ? |
factor | The exponential factor to use |
jitter | Random jitter in ms to add to the interval |
maxBackoff | Maximum delay before to retry |
1$ npm test
Coverage report can be found in coverage/.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/25 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
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