Skip to content

typescript.circuit_breaker

Stability High

Detects external service calls without circuit breaker protection.

Missing circuit breakers:

  • Cascade failures — One service down brings everything down
  • Resource exhaustion — Threads blocked waiting
  • No recovery — System stays broken after transient issues
// ❌ Before (no circuit breaker)
async function callPaymentService(payment: Payment): Promise<Receipt> {
return axios.post('/api/payments', payment);
}
// ✅ After (with circuit breaker)
import CircuitBreaker from 'opossum';
const breaker = new CircuitBreaker(
async (payment: Payment) => axios.post('/api/payments', payment),
{
timeout: 3000,
errorThresholdPercentage: 50,
resetTimeout: 30000,
}
);
async function callPaymentService(payment: Payment): Promise<Receipt> {
return breaker.fire(payment);
}
  • HTTP clients without circuit breakers
  • gRPC calls without protection
  • Database calls without failover

Unfault can add opossum circuit breaker wrapper.