Skip to content

Commit

Permalink
[fix] dont change opts object in backoff when we are ignoring the bac…
Browse files Browse the repository at this point in the history
…koff attempt (because one is already running)
  • Loading branch information
jcrugzz committed Sep 13, 2013
1 parent 149f5ea commit 975bb9f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions primus.js
Expand Up @@ -688,19 +688,19 @@ Primus.prototype.backoff = function backoff(callback, opts) {

var primus = this;

opts.maxDelay = opts.maxDelay || Infinity; // Maximum delay.
opts.minDelay = opts.minDelay || 500; // Minimum delay.
opts.retries = opts.retries || 10; // Amount of allowed retries.
opts.attempt = (+opts.attempt || 0) + 1; // Current attempt.
opts.factor = opts.factor || 2; // Back off factor.

//
// Bailout when we already have a backoff process running. We shouldn't call
// the callback then as it might cause an unexpected `end` event as another
// reconnect process is already running.
//
if (opts.backoff) return;

opts.maxDelay = opts.maxDelay || Infinity; // Maximum delay.
opts.minDelay = opts.minDelay || 500; // Minimum delay.
opts.retries = opts.retries || 10; // Amount of allowed retries.
opts.attempt = (+opts.attempt || 0) + 1; // Current attempt.
opts.factor = opts.factor || 2; // Back off factor.

//
// Bailout if we are about to make to much attempts. Please note that we use
// `>` because we already incremented the value above.
Expand Down

0 comments on commit 975bb9f

Please sign in to comment.