Web APIs

AbortSignal.timeout()

Try the free JavaScript compiler

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

NameTypeDescription
millisecondsnumberTimeout 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});
JavaScript Reference