Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

retry-request

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retry-request - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

31

index.js

@@ -38,3 +38,6 @@ 'use strict';

var MAX_NO_RESPONSE_RETRIES = 2;
var numAttempts = 0;
var numNoResponseAttempts = 0;

@@ -93,10 +96,24 @@ var retryStream;

function retryAfterDelay(numAttempts) {
if (streamMode) {
resetStreams();
}
setTimeout(makeRequest, getNextRetryDelay(numAttempts));
}
function onResponse(err, response, body) {
// An error such as DNS resolution.
if (err) {
if (streamMode) {
retryStream.emit('error', err);
retryStream.end();
numNoResponseAttempts++;
if (numNoResponseAttempts <= MAX_NO_RESPONSE_RETRIES) {
retryAfterDelay(numNoResponseAttempts);
} else {
callback(err, response, body);
if (streamMode) {
retryStream.emit('error', err);
retryStream.end();
} else {
callback(err, response, body);
}
}

@@ -109,7 +126,3 @@

if (numAttempts <= opts.retries && opts.shouldRetryFn(response)) {
if (streamMode) {
resetStreams();
}
setTimeout(makeRequest, getNextRetryDelay(numAttempts));
retryAfterDelay(numAttempts);
return;

@@ -116,0 +129,0 @@ }

{
"name": "retry-request",
"version": "2.0.0",
"version": "2.0.1",
"description": "Retry a request.",

@@ -8,3 +8,3 @@ "main": "index.js",

"scripts": {
"test": "mocha --timeout 12000"
"test": "mocha --timeout 0"
},

@@ -11,0 +11,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc