AbortSignal: abort() static method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2019.

Note: This feature is available in Web Workers.

The AbortSignal.abort() static method returns an AbortSignal that is already set as aborted (and which does not trigger an abort event).

This is shorthand for the following code:

js
const controller = new AbortController();
controller.abort();
return controller.signal;

This could, for example, be passed to a fetch method in order to run its abort logic (i.e. it may be that code is organized such that the abort logic should be run even if the intended fetch operation has not been started).

Note: The method is similar in purpose to Promise.reject.

Syntax

js
AbortSignal.abort()
AbortSignal.abort(reason)

Parameters

reason

The reason why the operation was aborted, which can be any JavaScript value. If not specified, the reason is set to "AbortError" DOMException.

Return value

An AbortSignal instance with the AbortSignal.aborted property set to true, and AbortSignal.reason set to the specified or default reason value.

Specifications

Specification
DOM
# ref-for-dom-abortsignal-abort①

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
abort() static method
reason parameter

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Has more compatibility info.