Creates an AbortController whose signal is linked to an optional
external AbortSignal.
Behaviour:
If externalSignal is undefined, returns a fresh controller with a
no-op cleanup.
If externalSignal is already aborted, the returned controller is
pre-aborted; cleanup is a no-op.
Otherwise, listens once for the external signal's abort event and
forwards it to the controller. cleanup removes the listener.
The internal controller MAY be aborted directly by the caller (e.g. to
apply a per-request timeout) without affecting the external signal —
propagation is one-way (external → internal).
Cleanup MUST be invoked after the awaited operation completes —
leaving a listener attached to a long-lived signal would retain a
reference to the controller and any captured closure state.
Creates an AbortController whose signal is linked to an optional external AbortSignal.
Behaviour:
externalSignalisundefined, returns a fresh controller with a no-opcleanup.externalSignalis already aborted, the returned controller is pre-aborted;cleanupis a no-op.abortevent and forwards it to the controller.cleanupremoves the listener.The internal controller MAY be aborted directly by the caller (e.g. to apply a per-request timeout) without affecting the external signal — propagation is one-way (external → internal).