/** * Executes an asynchronous action with retry support, exponential backoff, * optional jitter, per-attempt timeout, and {@link AbortController} cancellation. * * The action receives the current attempt index and an {@link AbortSignal}. * The signal should be passed to APIs that support cancellation (e.g. `fetch`, * `axios`, or custom logic). * * @typeParam T - The resolved value type of the action. * * @param action - Asynchronous function to execute. * Receives an object containing: * - `attempt`: Zero-based attempt index. * - `signal`: Abort signal for the current attempt. * * @param options - Optional retry configuration. * * @returns A promise that resolves with the successful result of `action`, * or rejects if all retries fail, retry conditions are not met, * or the operation is aborted. * * @throws {DOMException} * Throws an `AbortError` if the operation is aborted via `AbortController`. * ``` */ export declare const retryAsync: (action: (ctx: { attempt: number; signal: AbortSignal; }) => Promise, { max, delay, maxDelay, jitter, timeout, shouldRetry, signal: externalSignal, }?: RetryOptions) => Promise; /** * Configuration options for {@link retryAsync}. */ declare type RetryOptions = { /** * Maximum number of retry attempts. * * - `0` means no retries (only the initial attempt). * - Default: `2` */ max?: number; /** * Base delay in milliseconds before the first retry. * * Subsequent retries use exponential backoff: * `delay * 2^(attempt - 1)` * * Default: `300` */ delay?: number; /** * Maximum delay in milliseconds between retries. * * Prevents exponential backoff from growing indefinitely. * * Default: `5000` */ maxDelay?: number; /** * Adds random jitter to retry delays to avoid synchronized retries. * * When enabled, the final delay is multiplied by a random factor * between `0.5` and `1.5`. * * Default: `true` */ jitter?: boolean; /** * Per-attempt timeout in milliseconds. * * If the timeout is reached, the current attempt is aborted * via {@link AbortController}. This does NOT cancel underlying * operations that do not support `AbortSignal` (e.g. IndexedDB). * * Default: `undefined` (no timeout) */ timeout?: number; /** * Predicate function that determines whether a failed attempt * should be retried. * * Returning `false` immediately stops retries and rethrows the error. * * @param error - The error thrown by the previous attempt. * @returns `true` to retry, `false` to stop. * * Default: always retry */ shouldRetry?: (error: unknown) => boolean; /** * External {@link AbortSignal} used to cancel all attempts and retries. * * - Aborting this signal stops retries immediately. * - The signal is combined with a per-attempt abort signal. * - Aborting does NOT cancel operations that do not support AbortSignal. */ signal?: AbortSignal; }; export { }