Defined in: async-retryer.ts:60
TFn extends AnyAsyncFunction
optional backoff: "linear" | "exponential" | "fixed";Defined in: async-retryer.ts:68
The backoff strategy for retry delays:
'exponential': Wait time doubles with each attempt (1s, 2s, 4s, ...)
'linear': Wait time increases linearly (1s, 2s, 3s, ...)
'fixed': Same wait time for all attempts
'exponential'optional baseWait: number | (retryer) => number;Defined in: async-retryer.ts:73
Base wait time in milliseconds between retries, or a function that returns the wait time
1000optional enabled: boolean | (retryer) => boolean;Defined in: async-retryer.ts:78
Whether the retryer is enabled, or a function that determines if it's enabled
trueoptional initialState: Partial<AsyncRetryerState<TFn>>;Defined in: async-retryer.ts:82
Initial state to merge with the default state
optional jitter: number;Defined in: async-retryer.ts:87
Jitter percentage to add to retry delays (0-1). Adds randomness to prevent thundering herd.
0optional key: string;Defined in: async-retryer.ts:92
Optional key to identify this async retryer instance. If provided, the async retryer will be identified by this key in the devtools and PacerProvider if applicable.
optional maxAttempts: number | (retryer) => number;Defined in: async-retryer.ts:97
Maximum number of retry attempts, or a function that returns the max attempts
3optional maxExecutionTime: number;Defined in: async-retryer.ts:102
Maximum execution time in milliseconds for a single function call before aborting
Infinityoptional maxTotalExecutionTime: number;Defined in: async-retryer.ts:107
Maximum total execution time in milliseconds for the entire retry operation before aborting
Infinityoptional maxWait: number | (retryer) => number;Defined in: async-retryer.ts:112
Maximum wait time in milliseconds to cap retry delays, or a function that returns the max wait time
Infinityoptional onAbort: (reason, retryer) => void;Defined in: async-retryer.ts:116
Callback invoked when the execution is aborted (manually or due to timeouts)
"manual" | "execution-timeout" | "total-timeout" | "new-execution"
AsyncRetryer\<`TFn`\>
void
optional onError: (error, args, retryer) => void;Defined in: async-retryer.ts:123
Callback invoked when any error occurs during execution (including retries)
Error
Parameters\<`TFn`\>
AsyncRetryer\<`TFn`\>
void
optional onExecutionTimeout: (retryer) => void;Defined in: async-retryer.ts:131
Callback invoked when a single execution attempt times out (maxExecutionTime exceeded)
AsyncRetryer\<`TFn`\>
void
optional onLastError: (error, retryer) => void;Defined in: async-retryer.ts:135
Callback invoked when the final error occurs after all retries are exhausted
Error
AsyncRetryer\<`TFn`\>
void
optional onRetry: (attempt, error, retryer) => void;Defined in: async-retryer.ts:139
Callback invoked before each retry attempt
number
Error
AsyncRetryer\<`TFn`\>
void
optional onSettled: (args, retryer) => void;Defined in: async-retryer.ts:143
Callback invoked after execution completes (success or failure) of each attempt
Parameters\<`TFn`\>
AsyncRetryer\<`TFn`\>
void
optional onSuccess: (result, args, retryer) => void;Defined in: async-retryer.ts:147
Callback invoked when execution succeeds
Awaited\<`ReturnType`\<`TFn`\>>
Parameters\<`TFn`\>
AsyncRetryer\<`TFn`\>
void
optional onTotalExecutionTimeout: (retryer) => void;Defined in: async-retryer.ts:155
Callback invoked when the total execution time times out (maxTotalExecutionTime exceeded)
AsyncRetryer\<`TFn`\>
void
optional throwOnError: boolean | "last";Defined in: async-retryer.ts:163
Controls when errors are thrown:
'last': Only throw the final error after all retries are exhausted
true: Throw every error immediately (disables retrying)
false: Never throw errors, return undefined instead
'last'