Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
life0fun opened this issue Sep 13, 2013 · 0 comments
Closed

Comments

@life0fun
Copy link

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
+};
@tim-kos tim-kos closed this as completed in 41b80fb Sep 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant