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
}
}
There is an opossum example using the errorFilter property under the opossum-playground repo
https://github.com/nodeshift-starters/opossum-playground/tree/master/error-filter
Now, in your case probably the
err.statusis not returning the status code but an undefined (I'm guessing here since I don't have the full code) and the value returned from the errorFilter is not truthy.So opossum keeps considering it a failure.