All problems

Payment Circuit Breaker Keeps Old Failures After Success

Level 2 · node · Reliability · Circuit breaker recovery state error

Scenario

An order service opens a circuit breaker after consecutive failures from an external payment provider and temporarily blocks calls. Even after a successful payment between intermittent errors, one later failure opens the breaker earlier than expected. The gateway service records provider outcomes in the breaker, which tracks consecutive failures.

Requirements

- Reset the previous consecutive failure count to zero when a provider call succeeds - Open the breaker only when consecutive failures reach the threshold - Count a failure after success as the first failure of a new consecutive sequence - While open, do not call the provider and return circuit_open - Return provider_error for failures below the threshold

Acceptance criteria

  • A success after a failure resets the consecutive failure count to zero
  • With threshold 2, failure-success-failure does not open the breaker
  • Two consecutive failures open a threshold 2 breaker
  • An additional request while open does not call the provider
  • A successful provider response is returned as a gateway success