Skip to content

Commit

Permalink
Half-open state does not keep rejecting, and doesn't trigger a later …
Browse files Browse the repository at this point in the history
…re-try.
  • Loading branch information
jerryjvl authored and lance committed Dec 13, 2017
1 parent 9edc171 commit 04df6f7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class CircuitBreaker extends EventEmitter {
this.emit('cacheMiss');
}

if (this.opened && !this.pendingClose) {
if (!this.closed && !this.pendingClose) {
/**
* Emitted when the circuit breaker is open and failing fast
* @event CircuitBreaker#reject
Expand Down Expand Up @@ -432,7 +432,8 @@ function fail (circuit, err, args, latency) {
const stats = circuit.stats;
const errorRate = stats.failures / stats.fires * 100;
if (errorRate > circuit.options.errorThresholdPercentage ||
circuit.options.maxFailures >= stats.failures) {
circuit.options.maxFailures >= stats.failures ||
circuit.halfOpen) {
circuit.open();
}
}
Expand Down

0 comments on commit 04df6f7

Please sign in to comment.