App-vNext/Polly · error · ArgumentOutOfRangeException
Value must be equal to or greater than {resolutionOfCircuit.
Error message
Value must be equal to or greater than {resolutionOfCircuit.TotalMilliseconds} milliseconds. This is the minimum resolution of the CircuitBreaker timer. What it means
Thrown at policy-construction time by the legacy Polly v7 AdvancedCircuitBreaker when samplingDuration is smaller than the circuit breaker's internal timer resolution. The advanced breaker samples failures over fixed timeslices; the resolution is ResolutionOfCircuitTimer = 20ms, so samplingDuration must be at least 20 milliseconds. Below that, the sampling windows cannot be computed, hence ArgumentOutOfRangeException.
Source
Thrown at src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs:238
Action<Exception, CircuitState, TimeSpan, Context> onBreak,
Action<Context> onReset,
Action onHalfOpen)
{
var resolutionOfCircuit = TimeSpan.FromTicks(AdvancedCircuitController<EmptyStruct>.ResolutionOfCircuitTimer);
if (failureThreshold <= 0)
{
throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be greater than zero.");
}
if (failureThreshold > 1)
{
throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be less than or equal to one.");
}
if (samplingDuration < resolutionOfCircuit)
{
throw new ArgumentOutOfRangeException(nameof(samplingDuration), $"Value must be equal to or greater than {resolutionOfCircuit.TotalMilliseconds} milliseconds. This is the minimum resolution of the CircuitBreaker timer.");
}
if (minimumThroughput <= 1)
{
throw new ArgumentOutOfRangeException(nameof(minimumThroughput), "Value must be greater than one.");
}
if (durationOfBreak < TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(durationOfBreak), "Value must be greater than zero.");
}
if (onBreak == null)
{
throw new ArgumentNullException(nameof(onBreak));
}
if (onReset == null)View on GitHub (pinned to d0e46bdb1e)
Solutions
- Set samplingDuration to at least 20ms; a practically useful value is in the hundreds of milliseconds to seconds range (e.g. TimeSpan.FromSeconds(10)).
- Validate configured samplingDuration against TimeSpan.FromMilliseconds(20) and fall back to a sane default.
- Check the unit of any value read from config (seconds vs milliseconds) before constructing the TimeSpan.
Example fix
// before .AdvancedCircuitBreaker(0.5, TimeSpan.Zero, 10, TimeSpan.FromSeconds(30), ...); // after .AdvancedCircuitBreaker(0.5, TimeSpan.FromSeconds(10), 10, TimeSpan.FromSeconds(30), ...);
Defensive patterns
Strategy: validation
Validate before calling
var minResolution = TimeSpan.FromMilliseconds(20);
if (samplingDuration < minResolution) throw new ArgumentOutOfRangeException(nameof(samplingDuration), $"Must be >= {minResolution.TotalMilliseconds}ms.");
.AdvancedCircuitBreaker(failureThreshold, samplingDuration, minimumThroughput, durationOfBreak, onBreak, onReset, onHalfOpen); Type guard
static bool IsSamplingDurationValid(TimeSpan d) => d >= TimeSpan.FromMilliseconds(20);
Prevention
- Use a samplingDuration in the seconds range (e.g. 10s) for meaningful failure ratios.
- Verify the unit (seconds vs milliseconds) of any config value before building the TimeSpan.
- Default to a sane value when config is missing instead of 0.
When it happens
Trigger: Calling AdvancedCircuitBreaker/Async with samplingDuration less than 20ms (e.g. TimeSpan.Zero, TimeSpan.FromMilliseconds(1), or a negative/very small value).
Common situations: samplingDuration sourced from config that defaulted to 0 when the key was missing; a unit-conversion mistake (passing seconds where milliseconds were intended, or vice-versa, yielding a tiny value); passing TimeSpan.Zero by accident.
Related errors
- Value must be greater than zero.
- Value must be less than or equal to one.
- Value must be greater than one.
- The ttl for items to cache must be greater than zero.
- The ttl for items to cache must be greater than zero.
AI-assisted analysis of App-vNext/Polly@d0e46bdb1e (2026-08-13).
Data as JSON: /api/errors/ba51e5e7a988212e.
Report an issue: GitHub.