Web APIs
AbortSignal.timeout()
Creates a signal that aborts with a timeout reason after a host-scheduled delay. Exact timing is not guaranteed; some runtimes do not keep an otherwise idle process alive for the signal.
Formal Syntax & Structure
javascript syntaxjavascript
AbortSignal.timeout(milliseconds)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| milliseconds | number | Timeout duration in milliseconds. |
Return Value
AbortSignal
Signal scheduled to abort.
Working Example
Example Snippetjavascript
const s=AbortSignal.timeout(1); const keepAlive=setTimeout(()=>{},100); s.addEventListener("abort",()=>{console.log(s.reason.name); clearTimeout(keepAlive);},{once:true});