diegosouzapw/OmniRoute · error

[DDG-CB] Circuit breaker opened after

Error message

[DDG-CB] Circuit breaker opened after ${circuitBreaker.failures} consecutive failures — fast-failing for ${CB_COOLDOWN_MS}ms

What it means

The DuckDuckGo web search circuit breaker reached its failure threshold and transitioned to OPEN: all subsequent DDG search requests will fast-fail for CB_COOLDOWN_MS milliseconds instead of hitting the upstream. After the cooldown elapses, the breaker half-opens and lets the next request through to probe recovery.

Solutions

  1. Wait for the cooldown to elapse and the probe request to test recovery
  2. Check DuckDuckGo endpoint reachability (rate limiting, blocking)
  3. Route searches to an alternate provider while the breaker is open
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at open-sse/executors/duckduckgo-web.ts:42 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/06bfbf3aa2dc4c66. Report an issue: GitHub.

Appendix: source

Thrown at open-sse/executors/duckduckgo-web.ts:42

}

const circuitBreaker: CircuitBreakerState = { failures: 0, openedAt: 0 };

export function cbIsOpen(): boolean {
  if (circuitBreaker.openedAt === 0) return false;
  if (Date.now() - circuitBreaker.openedAt >= CB_COOLDOWN_MS) {
    // Cooldown elapsed — half-open: allow the next request through.
    circuitBreaker.openedAt = 0;
    return false;
  }
  return true;
}

export function cbRecordFailure(): void {
  circuitBreaker.failures++;
  if (circuitBreaker.failures >= CB_THRESHOLD && circuitBreaker.openedAt === 0) {
    circuitBreaker.openedAt = Date.now();
    console.warn(
      `[DDG-CB] Circuit breaker opened after ${circuitBreaker.failures} consecutive failures — fast-failing for ${CB_COOLDOWN_MS}ms`
    );
  }
}

export function cbRecordSuccess(): void {
  if (circuitBreaker.failures > 0) {
    circuitBreaker.failures = 0;
  }
}

// Test-only: direct read/write access to the module-level breaker singleton
// so tests can exercise open/half-open/closed transitions without waiting
// CB_COOLDOWN_MS in real time. Not used by production code.
export function __setDdgCircuitBreakerStateForTests(failures: number, openedAt: number): void {
  circuitBreaker.failures = failures;
  circuitBreaker.openedAt = openedAt;
}

View on GitHub (pinned to a179ffed5b)