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
- AbortSignal — The object from an AbortController that tells work it has been cancelled, through its aborted flag, its reason and an abort event.
- try...catch — A statement that runs code in a try block and, if that code throws an exception, runs a catch block instead of crashing.
Taught in
- Cancellation With AbortController And Async Signal Propagation — Frontend Architecture & Web Platform