Skip to main content
Version: 1.6.2

Function: signalToPromise()

signalToPromise(signal: AbortSignal): Promise<never>

Defined in: utils.ts:839

Converts an AbortSignal into a Promise that rejects when the signal is aborted.

The listener closure captures reject strongly and is held alive by the signal, so the promise cannot be GC'd while the signal is alive. The once option ensures the listener (and its reference to reject) is released as soon as the signal fires.

Parameters

ParameterTypeDescription
signalAbortSignalAbortSignal to convert

Returns

Promise<never>

Promise that rejects with the signal's reason when aborted