Web APIs

AbortController.prototype.abort()

Try the free JavaScript compiler

Marks the associated signal aborted once and notifies listeners. Subsequent calls leave the existing abort reason unchanged.

Formal Syntax & Structure

javascript syntaxjavascript
controller.abort(reason)

Parameters & Attributes

NameTypeDescription
reasonanyCancellation reason; omitted reason uses a host AbortError.

Return Value

undefined

No return value.

Working Example

Example Snippetjavascript
const c = new AbortController();c.signal.addEventListener("abort", () => console.log(c.signal.reason), {once:true});c.abort("stop"); c.abort("again");console.log(c.signal.aborted);
JavaScript Reference