New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

requestretry

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

requestretry - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

.jsbeautifyrc

45

index.js

@@ -10,4 +10,4 @@ 'use strict';

*/
var request = require('request');
var _ = require('fg-lodash');
var request = require('request');
var _ = require('fg-lodash');
var Cancelable = require('cancelable');

@@ -17,14 +17,14 @@

var DEFAULTS = {
maxAttempts: 5, // try 5 times
var DEFAULTS = {
maxAttempts: 5, // try 5 times
retryDelay: 5000, // wait for 5s before trying again
};
function Request(options, f, maxAttempts, retryDelay){
function Request(options, f, maxAttempts, retryDelay) {
this.maxAttempts = maxAttempts;
this.retryDelay = retryDelay;
this.options = options;
this.f = _.once(f);
this._timeout = null;
this._req = null;
this.retryDelay = retryDelay;
this.options = options;
this.f = _.once(f);
this._timeout = null;
this._req = null;
}

@@ -34,7 +34,7 @@

Request.prototype._tryUntilFail = function(){
Request.prototype._tryUntilFail = function () {
this.maxAttempts--;
this._req = Request.request(this.options, function(err, response, body){
if(this._isRetriable(err, response) && this.maxAttempts >= 0){
this._req = Request.request(this.options, function (err, response, body) {
if (this._isRetriable(err, response) && this.maxAttempts >= 0) {
this._timeout = setTimeout(this._tryUntilFail.bind(this), this.retryDelay);

@@ -48,3 +48,3 @@ return;

Request.prototype._isRetriable = function(err, response){
Request.prototype._isRetriable = function (err, response) {
// Inspired from https://github.com/geoffreak/request-enhanced/blob/master/src/request-enhanced.coffee#L107

@@ -54,4 +54,4 @@ return (err && _.contains(RETRIABLE_ERRORS, err.code)) || (response && 500 <= response.statusCode && response.statusCode < 600);

Request.prototype.abort = function(){
if(this._req){
Request.prototype.abort = function () {
if (this._req) {
this._req.abort();

@@ -63,3 +63,14 @@ }

function Factory(options, f){
// expose request methods from RequestRetry
['end', 'on', 'emit', 'once', 'setMaxListeners', 'start', 'removeListener', 'pipe'].forEach(function (methodName) {
Request.prototype[methodName] = makeGateway(methodName);
});
function makeGateway(methodName) {
return function () {
return this._req[methodName].apply(this._req, Array.prototype.slice.call(arguments));
};
}
function Factory(options, f) {
f = _.isFunction(f) ? f : _.noop;

@@ -66,0 +77,0 @@ var retry = _(options || {}).defaults(DEFAULTS).pick(Object.keys(DEFAULTS)).value();

{
"name": "requestretry",
"description": "request-retry wrap nodejs request to retry http(s) requests in case of error",
"version": "1.1.0",
"author": {

@@ -9,3 +10,8 @@ "name": "Francois-Guillaume Ribreau",

},
"version": "1.0.4",
"contributors": [
{
"name": "juliendangers",
"email": "dev@juliencrestin.com"
}
],
"repository": {

@@ -18,4 +24,4 @@ "url": "https://github.com/FGRibreau/node-request-retry"

"cancelable": "~0.1.0",
"fg-lodash": "0.0.1",
"request": "~2.44.0"
"fg-lodash": "0.0.2",
"request": "~2.47.0"
},

@@ -22,0 +28,0 @@ "devDependencies": {

@@ -40,2 +40,6 @@ # Request-retry [![Deps](https://david-dm.org/FGRibreau/node-request-retry.png)](https://david-dm.org/FGRibreau/node-request-retry)

v1.1.0
- support for 'end', 'on', 'emit', 'once', 'setMaxListeners', 'start', 'removeListener', 'pipe' request methods by @juliendangers
v1.0.4

@@ -42,0 +46,0 @@

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