Gathering detailed insights and metrics for retry-request
Gathering detailed insights and metrics for retry-request
Gathering detailed insights and metrics for retry-request
Gathering detailed insights and metrics for retry-request
is-retry-allowed
Check whether a request can be retried based on the `error.code`
vue-request
This is a library that can easily help you manage request states, supporting common features such as SWR, polling, error retry, caching, and pagination, etc.
superagent
elegant & feature rich browser / node HTTP with a fluent API
popsicle-retry
Enable request retries for Popsicle
**THIS REPOSITORY AND PACKAGE WILL BE DEPRECATED IN JULY 2024** Retry a request with built-in exponential backoff.
npm install retry-request
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (96.84%)
Python (3.16%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
67 Stars
181 Commits
16 Forks
50 Watchers
16 Branches
977 Contributors
Updated on Jun 18, 2025
Latest Version
8.0.0
Package Id
retry-request@8.0.0
Unpacked Size
20.68 kB
Size
6.71 kB
File Count
6
NPM Version
6.14.18
Node Version
14.21.3
Published on
Feb 19, 2025
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
THIS REPOSITORY AND PACKAGE WILL BE DEPRECATED IN JULY 2024. RELEVANT FUNCTIONALITIES HAVE BEEN MOVED TO GOOGLEAPIS/GAXIOS
![]() |
---|
Retry a request with built-in exponential backoff. |
1$ npm install --save teeny-request 2$ npm install --save retry-request
1var request = require('retry-request', { 2 request: require('teeny-request'), 3});
It should work the same as request
and teeny-request
in both callback mode and stream mode.
Note: This module only works when used as a readable stream, i.e. POST requests aren't supported (#3).
request
?Yes! You must independently install teeny-request
OR request
(deprecated) and provide it to this library:
1var request = require('retry-request', { 2 request: require('teeny-request'), 3});
urlThatReturns503
will be requested 3 total times before giving up and executing the callback.
1request(urlThatReturns503, function (err, resp, body) {});
urlThatReturns503
will be requested 3 total times before giving up and emitting the response
and complete
event as usual.
1request(urlThatReturns503) 2 .on('error', function () {}) 3 .on('response', function () {}) 4 .on('complete', function () {});
Yes! To enable the debug mode, set the environment variable DEBUG
to retry-request.
(Thanks for the implementation, @yihaozhadan!)
Passed directly to request
or teeny-request
. See the list of options supported:
opts.noResponseRetries
Type: Number
Default: 2
The number of times to retry after a response fails to come through, such as a DNS resolution error or a socket hangup.
1var opts = { 2 noResponseRetries: 0, 3}; 4 5request(url, opts, function (err, resp, body) { 6 // url was requested 1 time before giving up and 7 // executing this callback. 8});
opts.objectMode
Type: Boolean
Default: false
Set to true
if your custom opts.request
function returns a stream in object mode.
opts.retries
Type: Number
Default: 2
1var opts = { 2 retries: 4, 3}; 4 5request(urlThatReturns503, opts, function (err, resp, body) { 6 // urlThatReturns503 was requested a total of 5 times 7 // before giving up and executing this callback. 8});
opts.currentRetryAttempt
Type: Number
Default: 0
1var opts = { 2 currentRetryAttempt: 1, 3}; 4 5request(urlThatReturns503, opts, function (err, resp, body) { 6 // urlThatReturns503 was requested as if it already failed once. 7});
opts.shouldRetryFn
Type: Function
Default: Returns true
if http.incomingMessage.statusCode is < 200 or >= 400.
1var opts = { 2 shouldRetryFn: function (incomingHttpMessage) { 3 return incomingHttpMessage.statusMessage !== 'OK'; 4 }, 5}; 6 7request(urlThatReturnsNonOKStatusMessage, opts, function (err, resp, body) { 8 // urlThatReturnsNonOKStatusMessage was requested a 9 // total of 3 times, each time using `opts.shouldRetryFn` 10 // to decide if it should continue before giving up and 11 // executing this callback. 12});
opts.request
Type: Function
If we not provided we will throw an error advising you to provide it.
NOTE: If you override the request function, and it returns a stream in object mode, be sure to set opts.objectMode
to true
.
1var originalRequest = require('teeny-request').defaults({ 2 pool: { 3 maxSockets: Infinity, 4 }, 5}); 6 7var opts = { 8 request: originalRequest, 9}; 10 11request(urlThatReturns503, opts, function (err, resp, body) { 12 // Your provided `originalRequest` instance was used. 13});
opts.maxRetryDelay
Type: Number
Default: 64
The maximum time to delay in seconds. If retryDelayMultiplier results in a delay greater than maxRetryDelay, retries should delay by maxRetryDelay seconds instead.
opts.retryDelayMultiplier
Type: Number
Default: 2
The multiplier by which to increase the delay time between the completion of failed requests, and the initiation of the subsequent retrying request.
opts.totalTimeout
Type: Number
Default: 600
The length of time to keep retrying in seconds. The last sleep period will be shortened as necessary, so that the last retry runs at deadline (and not considerably beyond it). The total time starting from when the initial request is sent, after which an error will be returned, regardless of the retrying attempts made meanwhile.
Passed directly to request
. See the callback section: https://github.com/request/request/#requestoptions-callback.
No vulnerabilities found.
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 17/18 approved changesets -- score normalized to 9
Reason
SAST tool is not run on all commits -- score normalized to 2
Details
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
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