mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 06:12:10 +03:00
Merge pull request #930 from tombii/tombii/fix/circuit-breaker-stuck-open
fix(resilience): prevent circuit breaker stuck OPEN in combo path
This commit is contained in:
@@ -197,13 +197,21 @@ export class CircuitBreaker {
|
||||
// ─── Internal Methods ────────────────────────
|
||||
|
||||
_onSuccess() {
|
||||
if (this.state === STATE.HALF_OPEN) {
|
||||
if (this.state === STATE.OPEN) {
|
||||
// Direct call from combo path: timeout elapsed and request succeeded
|
||||
// without going through execute(), so transition OPEN → CLOSED directly
|
||||
this._transition(STATE.CLOSED);
|
||||
this.failureCount = 0;
|
||||
this.successCount = 0;
|
||||
this.lastFailureTime = null;
|
||||
} else if (this.state === STATE.HALF_OPEN) {
|
||||
this.successCount++;
|
||||
this._transition(STATE.CLOSED);
|
||||
this.failureCount = 0;
|
||||
} else {
|
||||
// In CLOSED state, just reset failure count
|
||||
this.failureCount = 0;
|
||||
}
|
||||
// In CLOSED state, just reset failure count
|
||||
this.failureCount = 0;
|
||||
this._persistToDb();
|
||||
}
|
||||
|
||||
@@ -211,7 +219,9 @@ export class CircuitBreaker {
|
||||
this.failureCount++;
|
||||
this.lastFailureTime = Date.now();
|
||||
|
||||
if (this.state === STATE.HALF_OPEN) {
|
||||
if (this.state === STATE.OPEN) {
|
||||
// Already OPEN — just update persistence (re-tripped by combo path)
|
||||
} else if (this.state === STATE.HALF_OPEN) {
|
||||
this._transition(STATE.OPEN);
|
||||
} else if (this.failureCount >= this.failureThreshold) {
|
||||
this._transition(STATE.OPEN);
|
||||
|
||||
Reference in New Issue
Block a user