Interface: RetryOptions
Options for retry.
Extends
Properties
backoff?
optionalbackoff?:RetryBackoff
How the delay grows per attempt:
fixed:delayevery timelinear:delay * attemptexponential:delay * 2^(attempt - 1)
Default Value
delay?
optionaldelay?:number
Base delay between attempts in milliseconds.
Default Value
jitter?
optionaljitter?:boolean
Adds randomness (delay * (0.5 ~ 1)) to avoid thundering-herd retries.
Disable for deterministic timing (e.g. in tests).
Default Value
maxDelay?
optionalmaxDelay?:number
Upper bound for the computed delay, in milliseconds.
Default Value
onRetry?
optionalonRetry?: (error,attempt,nextDelay) =>void
Called before each retry — a good place for logging.
Parameters
error
unknown
The error thrown by the failed attempt.
attempt
number
The attempt number that just failed (1-based).
nextDelay
number
The delay before the next attempt, in milliseconds.
Returns
void
retries?
optionalretries?:number
Number of retries after the first attempt fails.
Default Value
shouldRetry?
optionalshouldRetry?: (error,attempt) =>boolean
Decides whether a failure is worth retrying. Return false to
rethrow immediately — e.g. business errors like 4xx usually should
not be retried, while network errors and 5xx should.
Parameters
error
unknown
The error thrown by the failed attempt.
attempt
number
The attempt number that just failed (1-based).
Returns
boolean
signal?
optionalsignal?:AbortSignal
Cancels the operation. While waiting between attempts or polls the cancellation is observed immediately; an in-flight attempt is not interrupted (abort the underlying work yourself if needed).
