Skip to content

Commit dd4ebc0

Browse files
abacajAnton Bacaj
authored andcommitted
fix retry counting
1 parent 51e9a8d commit dd4ebc0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

resolute.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(function() {
22
var Resolute = function(opt, callback) {
3-
var self = this;
43
opt = opt || {};
54
this.operation = opt.operation;
65
this.maxRetry = opt.maxRetry || 3;
@@ -11,7 +10,7 @@
1110
Resolute.prototype.run = function(operation) {
1211
var self = this;
1312

14-
var checkForPromise = function(opt) {
13+
var _checkForPromise = function(opt) {
1514
// Do we have a operation?
1615
var operation = (typeof opt === "undefined") ? this.operation : opt;
1716

@@ -25,7 +24,7 @@
2524
}
2625
};
2726

28-
var fn = checkForPromise.call(self, operation);
27+
var _fn = _checkForPromise.call(self, operation);
2928

3029
var _delay = function(ms) {
3130
return new Promise(function(resolve, reject) {
@@ -34,7 +33,7 @@
3433
};
3534

3635
var _retry = function(retryCount, maxRetry, fn, delay) {
37-
retryCount = retryCount || 0;
36+
retryCount = retryCount || 1;
3837
var retryMechanism = function(err) {
3938
if (retryCount >= maxRetry) {
4039
throw err;
@@ -49,7 +48,7 @@
4948
return fn.then(null, retryMechanism);
5049
};
5150

52-
return _retry(0, self.maxRetry, fn, self.delay);
51+
return _retry(1, self.maxRetry, _fn, self.delay);
5352
};
5453

5554
// CommonJS module

0 commit comments

Comments
 (0)