I am building an express api and have implemented a circuit breaker in it using opossum.
Is there a way for the circuit breaker to ignore the custom HTTP exceptions generated from application?
I have tried adding the errorFilter
option but getting the same issue. It is still considering it as a circuit failure.
const options: CircuitOptions = {
timeout: 3000, // If function takes longer than 3 seconds, trigger a failure
errorThresholdPercentage: 50, // When 50% of the requests fail, trip the circuit
resetTimeout: 30000, // After 30 seconds try again
errorFilter: err => {
// Filtering out Http404Error here.
return err.status === 404 // Not Working
}
}
Just resolved the same issue.
In my case I was doing the request using
axios
so the response status is intoerr.response.status
. And in the same way that point alexalikiotis, usingerr.status === 404
it was evaluated asundefined === 404
.So this code works fine for me doing calls over the network using
axios
: