Skip to content

Commit

Permalink
fix: avoid calling fallback function twice (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
duartemendes committed May 26, 2018
1 parent 1a61f56 commit d251820
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,12 @@ class CircuitBreaker extends EventEmitter {
}
})
.catch(error => {
this.semaphore.release();
const latencyEndTime = Date.now() - latencyStartTime;
handleError(
error, this, timeout, args, latencyEndTime, resolve, reject);
if (!timeoutError) {
this.semaphore.release();
const latencyEndTime = Date.now() - latencyStartTime;
handleError(
error, this, timeout, args, latencyEndTime, resolve, reject);
}
});
} catch (error) {
this.semaphore.release();
Expand Down

0 comments on commit d251820

Please sign in to comment.