awaitAbort()function

awaitAbort(signal: AbortSignal): Promise<never>
ParamType
signalAbortSignal
The AbortSignal to watch. required
Return
Promise<never>
A promise that never resolves and rejects with the signal's reason when it fires.
Throws
unknown
The signal's reason when the signal aborts.

Get a promise that rejects with the signal's reason when an AbortSignal fires.

  • Rejects immediately if the signal is already aborted.
  • Use with awaitRace() to cancel a concurrent operation when a signal fires.

Examples

await awaitRace(getDelay(300), awaitAbort(signal));