Function: raceWithAbort()
raceWithAbort<
T>(operation:Promise<T>,signal:AbortSignal):Promise<T>
Defined in: shared/utils/abortUtils.ts:440
Races a promise against an AbortSignal.
Type Parametersโ
Tโ
T
Resolved value of the underlying operation.
Parametersโ
operationโ
Promise<T>
Promise to monitor.
signalโ
Abort signal to race against.
Returnsโ
Promise<T>
The first settled result between the promise and the abort event.
Remarksโ
Useful for APIs without native abort support. The returned promise rejects as soon as the signal aborts, allowing callers to adopt a uniform cancellation flow.
Exampleโ
const controller = new AbortController();
const result = await raceWithAbort(
    someNonAbortableOperation(),
    controller.signal
);
Throwsโ
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When the signal aborts before the operation settles.