Socket
Socket
Sign inDemoInstall

retry

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retry - npm Package Compare versions

Comparing version 0.12.0 to 0.13.1

16

lib/retry_operation.js

@@ -18,2 +18,3 @@ function RetryOperation(timeouts, options) {

this._operationStart = null;
this._timer = null;

@@ -28,3 +29,3 @@ if (this._options.forever) {

this._attempts = 1;
this._timeouts = this._originalTimeouts;
this._timeouts = this._originalTimeouts.slice(0);
}

@@ -36,2 +37,5 @@

}
if (this._timer) {
clearTimeout(this._timer);
}

@@ -52,2 +56,3 @@ this._timeouts = [];

if (err && currentTime - this._operationStart >= this._maxRetryTime) {
this._errors.push(err);
this._errors.unshift(new Error('RetryOperation timeout occurred'));

@@ -63,5 +68,4 @@ return false;

// retry forever, only keep last error
this._errors.splice(this._errors.length - 1, this._errors.length);
this._timeouts = this._cachedTimeouts.slice(0);
timeout = this._timeouts.shift();
this._errors.splice(0, this._errors.length - 1);
timeout = this._cachedTimeouts.slice(-1);
} else {

@@ -73,3 +77,3 @@ return false;

var self = this;
var timer = setTimeout(function() {
this._timer = setTimeout(function() {
self._attempts++;

@@ -91,3 +95,3 @@

if (this._options.unref) {
timer.unref();
this._timer.unref();
}

@@ -94,0 +98,0 @@

@@ -6,3 +6,3 @@ var RetryOperation = require('./retry_operation');

return new RetryOperation(timeouts, {
forever: options && options.forever,
forever: options && (options.forever || options.retries === Infinity),
unref: options && options.unref,

@@ -55,3 +55,3 @@ maxRetryTime: options && options.maxRetryTime

var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
timeout = Math.min(timeout, opts.maxTimeout);

@@ -58,0 +58,0 @@

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "0.12.0",
"version": "0.13.1",
"homepage": "https://github.com/tim-kos/node-retry",

@@ -13,6 +13,10 @@ "repository": {

},
"files": [
"lib",
"example"
],
"directories": {
"lib": "./lib"
},
"main": "index",
"main": "index.js",
"engines": {

@@ -19,0 +23,0 @@ "node": ">= 4"

<!-- badges/ -->
[![Build Status](https://secure.travis-ci.org/tim-kos/node-retry.png?branch=master)](http://travis-ci.org/tim-kos/node-retry "Check this project's build status on TravisCI")
[![Build Status](https://secure.travis-ci.org/tim-kos/node-retry.svg?branch=master)](http://travis-ci.org/tim-kos/node-retry "Check this project's build status on TravisCI")
[![codecov](https://codecov.io/gh/tim-kos/node-retry/branch/master/graph/badge.svg)](https://codecov.io/gh/tim-kos/node-retry)

@@ -65,3 +65,3 @@ <!-- /badges -->

Creates a new `RetryOperation` object. `options` is the same as `retry.timeouts()`'s `options`, with two additions:
Creates a new `RetryOperation` object. `options` is the same as `retry.timeouts()`'s `options`, with three additions:

@@ -68,0 +68,0 @@ * `forever`: Whether to retry forever, defaults to `false`.

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