throwIfAborted()

An AbortSignal method that throws the signal's abort reason if it has been aborted, and does nothing otherwise.

In more detail

It lets synchronous loops honour cancellation, not just asynchronous APIs. Calling it at the top of each loop step is the simplest way to make long-running code stop promptly when cancelled.

Related terms

Taught in

References