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 by the async AdvancedCircuitBreakerAsync<T> syntax when samplingDuration is below the 20ms minimum timer resolution. The advanced circuit needs windows of at least ResolutionOfCircuitTimer (20ms). Fires at policy construction.

Source

Thrown at src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs:231

    /// <exception cref="ArgumentNullException">Thrown when <paramref name="onReset"/> is <see langword="null"/>.</exception>
    /// <exception cref="ArgumentNullException">Thrown when <paramref name="onHalfOpen"/> is <see langword="null"/>.</exception>
    public static AsyncCircuitBreakerPolicy<TResult> AdvancedCircuitBreakerAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, double failureThreshold, TimeSpan samplingDuration, int minimumThroughput, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, 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

  1. Use a samplingDuration of at least 20ms (prefer seconds-scale windows).
  2. Validate the duration against TimeSpan.FromMilliseconds(20) before building.
  3. Confirm config units match what the API expects.

Example fix

// before
.AdvancedCircuitBreakerAsync(..., samplingDuration: TimeSpan.FromMilliseconds(10), ...)

// after
.AdvancedCircuitBreakerAsync(..., samplingDuration: TimeSpan.FromSeconds(10), ...)
Defensive patterns

Strategy: validation

Validate before calling

if (samplingDuration < TimeSpan.FromMilliseconds(20))
    throw new ArgumentOutOfRangeException(nameof(samplingDuration), "samplingDuration must be >= 20ms.");

Type guard

static bool IsValidSamplingDuration(TimeSpan d) => d >= TimeSpan.FromMilliseconds(20);

Prevention

When it happens

Trigger: Calling AdvancedCircuitBreakerAsync(..., samplingDuration: TimeSpan.FromMilliseconds(10), ...) or TimeSpan.Zero. The check is `samplingDuration < resolutionOfCircuit` (20ms).

Common situations: TimeSpan.Zero placeholder, wrong config units, or a 0/default value from config.

Related errors


AI-assisted analysis of App-vNext/Polly@d0e46bdb1e (2026-08-13). Data as JSON: /api/errors/fffb1ba16c53028c. Report an issue: GitHub.