Skip to content

createTimeoutSignal

function createTimeoutSignal(
callerSignal,
timeoutMs,
label): {
cleanup: () => void;
signal: AbortSignal;
};

Defined in: packages/engine/src/utilities/TimeoutSignal.ts:13

Multiplex an optional caller AbortSignal with a hard timeout into a single AbortSignal suitable for fetch().

Implemented manually rather than with AbortSignal.any()/AbortSignal.timeout() (Chrome 116+) to stay compatible with the TypeScript lib targets used by this project.

Handles the already-aborted caller: addEventListener(“abort”, …) on a signal that has already fired never invokes the listener, so without the upfront aborted check the fetch would proceed even though the caller cancelled.

ParameterType
callerSignalAbortSignal | undefined
timeoutMsnumber
labelstring
{
cleanup: () => void;
signal: AbortSignal;
}
cleanup: () => void;

void

signal: AbortSignal;