I noticed when writing tests that setting some options to 0 is not working as I expected.
An example is errorThresholdPercentage, which I wanted to set to 0 in a test to make it fail immediately. But setting it to 0 will result in the default value 50 being used!
Is that the expected behaviour?
The reason why this happens is in how the defaults are set in the CircuitBreaker constructor.
Problem
I noticed when writing tests that setting some
options
to0
is not working as I expected.An example is
errorThresholdPercentage
, which I wanted to set to0
in a test to make it fail immediately. But setting it to0
will result in the default value50
being used!Is that the expected behaviour?
The reason why this happens is in how the defaults are set in the
CircuitBreaker
constructor.https://github.com/nodeshift/opossum/blob/main/lib/circuit.js#L157C5-L158C46
Since
0
is consideredfalse
it will take the50
.Similar behaviour is also present for the options
resetTimeout
,rollingCountTimeout
,rollingCountBuckets
.