Skip to main content

Function: retryWithAbort()

retryWithAbort<T>(operation: () => Promise<T>, options: RetryWithAbortOptions): Promise<T>

Defined in: shared/utils/abortUtils.ts:259

Implements retry logic with abort signal support.

Type Parametersโ€‹

Tโ€‹

T

Parametersโ€‹

operationโ€‹

() => Promise<T>

Function to retry

optionsโ€‹

RetryWithAbortOptions = {}

Retry configuration

Returnsโ€‹

Promise<T>

Promise that resolves to the operation result

Remarksโ€‹

Provides exponential backoff retry logic that respects abort signals. Will stop retrying immediately if the signal is aborted.

Exampleโ€‹

const controller = new AbortController();

const result = await retryWithAbort(
async () => {
const response = await fetch(url);
if (!response.ok) throw new https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error("Request failed");
return response.json();
},
{
maxRetries: 3,
initialDelay: 1000,
signal: controller.signal,
}
);

Throwsโ€‹

When all retries are exhausted or operation is aborted