Skip to content

RetryWithExponentialBackoffRespectingRetryHeaders

Namespace: Vercel.AI.Util

public sealed class RetryWithExponentialBackoffRespectingRetryHeaders

Retries a failed operation with exponential backoff, honoring retry-after-ms and retry-after when the delay is between 0 and 60 seconds, or shorter than the backoff delay.

Inheritance: object

View source

RetryWithExponentialBackoffRespectingRetryHeaders(RetryOptions?)

Section titled “RetryWithExponentialBackoffRespectingRetryHeaders(RetryOptions?)”
public RetryWithExponentialBackoffRespectingRetryHeaders(RetryOptions? options = null)

Creates a retry strategy.

Parameters

Name Type Description
options RetryOptions

View source

public Task<T> ExecuteAsync<T>(Func<Task<T>> operation)

Runs <code class=“paramref”>operation</code> until it succeeds or retries stop.

Type parameters

Name Description
T

Parameters

Name Type Description
operation Func<Task<T>>

Returns: Task<T>

View source

GetRetryDelayInMs(object, double, DateTimeOffset?)

Section titled “GetRetryDelayInMs(object, double, DateTimeOffset?)”
public static double GetRetryDelayInMs(object error, double exponentialBackoffDelay, DateTimeOffset? utcNow = null)

Delay in milliseconds for <code class=“paramref”>error</code> given the current exponential delay. Header delays are used when they are at least 0 and either under 60 seconds or shorter than the backoff.

Parameters

Name Type Description
error object
exponentialBackoffDelay double
utcNow DateTimeOffset?

Returns: double

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product