{"record":{"id":"06bfbf3aa2dc4c66","repo":"diegosouzapw/OmniRoute","slug":"ddg-cb-circuit-breaker-opened-after-circuitbre","errorCode":null,"errorMessage":"[DDG-CB] Circuit breaker opened after ${circuitBreaker.failures} consecutive failures — fast-failing for ${CB_COOLDOWN_MS}ms","messagePattern":"\\[DDG-CB\\] Circuit breaker opened after (.+?) consecutive failures — fast-failing for (.+?)ms","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"open-sse/executors/duckduckgo-web.ts","lineNumber":42,"sourceCode":"}\n\nconst circuitBreaker: CircuitBreakerState = { failures: 0, openedAt: 0 };\n\nexport function cbIsOpen(): boolean {\n  if (circuitBreaker.openedAt === 0) return false;\n  if (Date.now() - circuitBreaker.openedAt >= CB_COOLDOWN_MS) {\n    // Cooldown elapsed — half-open: allow the next request through.\n    circuitBreaker.openedAt = 0;\n    return false;\n  }\n  return true;\n}\n\nexport function cbRecordFailure(): void {\n  circuitBreaker.failures++;\n  if (circuitBreaker.failures >= CB_THRESHOLD && circuitBreaker.openedAt === 0) {\n    circuitBreaker.openedAt = Date.now();\n    console.warn(\n      `[DDG-CB] Circuit breaker opened after ${circuitBreaker.failures} consecutive failures — fast-failing for ${CB_COOLDOWN_MS}ms`\n    );\n  }\n}\n\nexport function cbRecordSuccess(): void {\n  if (circuitBreaker.failures > 0) {\n    circuitBreaker.failures = 0;\n  }\n}\n\n// Test-only: direct read/write access to the module-level breaker singleton\n// so tests can exercise open/half-open/closed transitions without waiting\n// CB_COOLDOWN_MS in real time. Not used by production code.\nexport function __setDdgCircuitBreakerStateForTests(failures: number, openedAt: number): void {\n  circuitBreaker.failures = failures;\n  circuitBreaker.openedAt = openedAt;\n}","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/executors/duckduckgo-web.ts#L24-L60","documentation":"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.","triggerScenarios":"Thrown at open-sse/executors/duckduckgo-web.ts:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the cooldown to elapse and the probe request to test recovery","Check DuckDuckGo endpoint reachability (rate limiting, blocking)","Route searches to an alternate provider while the breaker is open"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}