withRetry
withRetry<
T>(op,opts?):Promise<T>
Defined in: packages/core/src/async/retry.ts:155
Run op with exponential backoff on retryable failures. Retries only on
network/5xx errors per isRetryableError; re-throws everything else
immediately so logic and 4xx errors surface fast.
Backoff schedule: baseMs * 2^(attempt-1) with jitter in [0.5, 1)x of
that delay. An AbortSignal cancels any pending sleep and rejects with
the signal’s reason.
Re-throw contract: on exhaustion the last caught error is re-thrown
unchanged. Non-retryable errors are also re-thrown as-is on the first
attempt. Callers see the real driver exception (which store adapters
wrap in StoreError via their own wrap helper further up the stack).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”() => Promise<T>
RetryOptions = {}
Returns
Section titled “Returns”Promise<T>
Throws
Section titled “Throws”TypeError when opts.attempts is not a positive integer — a
configuration bug, thrown before op runs so the failure is loud.
Throws
Section titled “Throws”DOMException with name === 'AbortError' when opts.signal
is already aborted at entry, or aborts during a pending sleep.
Throws
Section titled “Throws”re-throws the caller’s own error — whatever op surfaces — when
it is classified non-retryable (first occurrence) or when retry
attempts are exhausted (last occurrence).