tim-kos / node-retry

Abstraction for exponential and custom retry strategies for failed operations.
Other
1.22k stars 80 forks source link

Getting NPE from retry_attempt.js #53

Closed cfurst closed 6 years ago

cfurst commented 6 years ago

if (this._options.unref) { ^

TypeError: Cannot read property 'unref' of undefined retry_operation.js:63:24

sometimes unref is unset. This generally happens when we have many different instances of operation are obtained from retry.operation() calls and one of them is retried. This is in v0.10.1

basically something like:

var retry = require('retry');
function myRetry(simpleFunction) {
// declare options here
    var operation = retry.operation(options);
    operation.attempt(simpleFunction, timeOutOptions);
}

setInterval(myRetry(function(attempt) {
   // ....
}, 1000);
cfurst commented 6 years ago

I see this is fixed in master:

if (self._options.unref) {
          self._timeout.unref();
      }

instead of

if (this._options.unref) {
          self._timeout.unref();
      }

is there a release with this change out yet?