RetryOptions

import { RetryOptions } from "jsr:@ende/async/unstable-retry";

interface ยท experimental

interface RetryOptions extends StableRetryOptions

Options for retry.

Properties

getDelay

getDelay?: ((error: unknown, attempt: number, computedDelay: number) => number) | undefined

Selects how long to wait before an eligible retry.

Called once before each retry, after isRetriable accepted the error and the attempt budget was checked, and never on success, on exhaustion, for a non-retriable error, or when signal is already aborted. A wait that is selected here can still be cancelled by signal.

The returned value replaces the whole wait: minTimeout, maxTimeout and jitter shape the computedDelay passed in, but are not applied to the result. Returning computedDelay keeps the backoff. Infinity waits until cancellation rather than stopping the retries.

The callback is synchronous and its result is never awaited. If it throws, retry rejects with that value and makes no further attempts.

Default: undefined

Returns

The number of milliseconds to wait before the next attempt.

Source