Skip to content

increase attempts at the time when retry function starts to execute #10

@life0fun

Description

@life0fun

Quick fix to ensure attempts got increased at the time when retry function got invoked.
Otherwise, the _attempts is not accurate as the retry actually got executed after timeout.
Too lazy for a pull request. Just paste the patch here.

diff --git a/lib/retry_operation.js b/lib/retry_operation.js
index f24d2d5..07add06 100644
--- a/lib/retry_operation.js
+++ b/lib/retry_operation.js
@@ -25,10 +25,9 @@ RetryOperation.prototype.retry = function(err) {
     return false;
   }

-  this._attempts++;
-
   var self = this;
   setTimeout(function() {
+    self._attempts++;
     self._fn(self._attempts);

     if (self._operationTimeoutCb) {
@@ -106,4 +105,4 @@ RetryOperation.prototype.mainError = function() {
   }

   return mainError;
-};
\ No newline at end of file
+};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions