AbortSignal.timeout()
A function that returns a signal which aborts itself after a given number of milliseconds, with a TimeoutError.
In more detail
The timer starts when the signal is created, and the abort reason is a DOMException named TimeoutError. fetch(url, { signal: AbortSignal.timeout(5000) }) gives up after five seconds without writing any timer code.
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.
- AbortSignal.any() — A function that combines several signals into one that aborts as soon as any of them does.
Taught in
- Cancellation With AbortController And Async Signal Propagation — Frontend Architecture & Web Platform