timeout static method

AbortSignal timeout(
  1. int milliseconds
)

The AbortSignal.timeout() static method returns an AbortSignal that will automatically abort after a specified time.

The signal aborts with a TimeoutError DOMException on timeout, or with AbortError DOMException due to pressing a browser stop button (or some other inbuilt "stop" operation). This allows UIs to differentiate timeout errors, which typically require user notification, from user-triggered aborts that do not.

The timeout is based on active rather than elapsed time, and will effectively be paused if the code is running in a suspended worker, or while the document is in a back-forward cache ("bfcache").

To combine multiple signals, you can use AbortSignal.any_static, for example, to directly abort a download using either a timeout signal or by calling AbortController.abort.

Implementation

external static AbortSignal timeout(int milliseconds);