Skip to content

Commit d17d79c

Browse files
committed
fix comment about half-open state
1 parent 8150b3c commit d17d79c

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

lib/CircuitBreaker/AbstractCircuitBreaker.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import type {CircuitBreakerOptions, CircuitBreakerState} from './types';
77
*
88
* - **closed**: requests are allowed; failures are counted.
99
* - **open**: requests are rejected until {@link resetTimeoutMs} elapses.
10-
* - **half-open**: the recovery-probe state. After the open timeout the breaker does NOT jump straight
11-
* back to closed (that would re-admit full load onto a still-broken dependency and immediately
12-
* re-trip — flapping). Instead it admits exactly ONE probe request: success means the dependency
13-
* recovered, so the circuit closes; failure means it's still down, so the circuit reopens for
14-
* another window. Admitting a single probe (see {@link isAllowed}) — rather than reopening the
15-
* floodgates — is also what avoids the "thundering herd" of every caller retrying at once.
10+
* - **half-open**: the recovery-probe state. After the open timeout, the breaker admits exactly ONE
11+
* probe request: success means the dependency recovered, so the circuit closes. Failure means it's
12+
* still down, so the circuit reopens. This single-request probe prevents a "thundering herd" where
13+
* every caller fails loudly when the service hasn't recovered yet.
1614
*
1715
* Subclasses implement the failure-counting policy by overriding {@link recordFailureInClosed} (and
1816
* friends) — e.g. counting consecutive failures, or failures within a rolling time window, or any

0 commit comments

Comments
 (0)