Function: raceWithTimeout()
raceWithTimeout<
T>(operation:Promise<T>,options:RaceWithTimeoutOptions):Promise<T>
Defined in: shared/utils/abortUtils.ts:670
Races an operation promise against a timeout (and optional AbortSignal).
Type Parametersโ
Tโ
T
Resolved value of the underlying operation.
Parametersโ
operationโ
Promise<T>
Promise to race.
optionsโ
Timeout and optional abort configuration.
Returnsโ
Promise<T>
The first settled result between the operation, timeout, and abort.
Remarksโ
This helper is intended for APIs that do not support abort natively. Timeout
rejections are regular https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error instances (not abort errors) so callers can
distinguish "timed out" from user cancellation when desired.
When unrefTimer is enabled and the runtime exposes unref() on timer
handles (Node.js/Electron), the timeout will not keep the event loop alive.
Throwsโ
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error when the timeout elapses.
Throwsโ
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error when the abort signal triggers (via raceWithAbort).