Skip to content

Retry

The retry option auto-retries on timeout and business failures; manual abort (abort() or external abortSignal) does not retry.

typescript
const loader = new AsyncLoader(
    (args) => fetch("/api/data", { signal: args.abortSignal }),
    {
        timeout: 5_000, // 5 seconds per attempt
        retry: 3, // up to 3 retries (4 attempts total)
        retryDelay: 1_000, // wait 1 second before each retry
    }
);

Retry rules

Failure typeRetries?
Business error (loader throws / rejects)✅ Yes
Timeout (triggered by timeout)✅ Yes
Manual abort()❌ No
External abortSignal abort❌ No
OptionDefaultDescription
retry0Max retry count (retry: 3 means up to 4 attempts total)
retryDelay0Milliseconds to wait before each retry
timeoutPer-attempt loading timeout; a timeout counts as a retryable failure

Abort terminates retry wait

When you call abort() during a retry wait, the wait is terminated as well.

Released under the MIT License.