Use the opossum library to wrap calls to downstream services. Configure errorThresholdPercentage to open the circuit after a failure rate is exceeded and resetTimeout to attempt recovery. Register a fallback function that returns safe default data when the circuit is open so the application degrades gracefully.
Closed — normal operation; requests flow through; failure rate is tracked.
Open — circuit tripped; requests fail immediately with the fallback value; upstream is not called.
Half-open — after resetTimeout; one test request is allowed through to check recovery.
Pair circuit breakers with retry logic — but retries amplify load on an already-struggling service.
Export circuit breaker metrics (open/close events) to your monitoring system for alerting.