Skip to content

External API fetches aren't protected by the circuit breaker #55

Description

@2ndtlmining

Labels: enhancement, reliability

Problem

src/lib/db/circuitBreaker.js exists and is used for database calls and the revenue sync (revenueScheduler.js calls shouldAllowRequest() / recordSuccess() / recordFailure(), including auto-failover to a backup DB instance on sustained failure). But gamingService.js, cryptoService.js, wordpressService.js, and nodeService.js never call into it for their calls to the Flux stats API (stats.runonflux.io). A sustained outage on that API just causes repeated retries (where retry logic exists) or immediate throws (where it doesn't), with no backoff and no way to signal degraded state the way DB outages do via getCircuitState().

Solution

Lower priority than Issues 1–4, but worth doing as part of the Issue 3 refactor since those files are already being touched: have the shared resilientFetch() helper call shouldAllowRequest() before attempting a fetch, and recordSuccess()/recordFailure() around it, mirroring the pattern already in revenueScheduler.js.

Files: src/lib/services/gamingService.js, cryptoService.js, wordpressService.js, nodeService.js, src/lib/db/circuitBreaker.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions