goldies
    Preparing search index...

    Interface RetryOptions

    Options for retry.

    interface RetryOptions {
        attempts?: number;
        delay?: number;
        factor?: number;
        shouldRetry?: (error: unknown, attempt: number) => boolean;
        signal?: AbortSignal;
    }
    Index
    attempts?: number

    How many times to call the function in total, including the first. Defaults to 3.

    delay?: number

    How long to wait before the first retry, in milliseconds. Defaults to 1000.

    factor?: number

    What to multiply the wait by after each retry. Defaults to 2: with the default delay, waits of 1s, 2s, 4s... Use 1 for a fixed delay.

    shouldRetry?: (error: unknown, attempt: number) => boolean

    Decides whether an error is worth retrying, such as a network failure but not a 404. Defaults to retrying every error.

    signal?: AbortSignal

    Stops retrying when aborted: retry rejects with the signal's reason, and doesn't start another attempt. To also cancel the attempt in progress, pass the same signal to the work itself, such as fetch.