AbortController and AbortSignal
The AbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired.
You can create a new AbortController object using the AbortController() constructor. Communicating with an asynchronous operation is done using an AbortSignal object.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 66 | 16 | 57 | 12.1 | 66 | 12.2 | |
| The abort() method of the AbortController interface aborts an asynchronous operation before it has completed. This is able to abort fetch requests, the consumption of any response bodies, or streams. | 66 | 16 | 57 | 12.1 | 66 | 12.2 |
abort (reason parameter) `reason` parameter | 98 | 98 | 97 | 15.4 | 98 | 15.4 |
| The AbortController() constructor creates a new AbortController object instance. | 66 | 16 | 57 | 12.1 | 66 | 12.2 |
| The signal read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired. | 66 | 16 | 57 | 12.1 | 66 | 12.2 |
| The AbortSignal interface represents a signal object that allows you to communicate with an asynchronous operation (such as a fetch request) and abort it if required via an AbortController object. | 66 | 16 | 57 | 11.1 | 66 | 11.3 |
| The abort event of the AbortSignal is fired when the associated request is aborted, i.e., using AbortController.abort(). | 66 | 16 | 57 | 11.1 | 66 | 11.3 |
| The AbortSignal.abort() static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event). | 93 | 93 | 88 | 15 | 93 | 15 |
abort_static (reason parameter) `reason` parameter | 98 | 98 | 97 | 15.4 | 98 | 15.4 |
| The aborted read-only property returns a value that indicates whether the asynchronous operations the signal is communicating with are aborted (true) or not (false). | 66 | 16 | 57 | 11.1 | 66 | 11.3 |
| The reason read-only property returns a JavaScript value that indicates the abort reason. | 98 | 98 | 97 | 15.4 | 98 | 15.4 |
| The throwIfAborted() method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing. | 100 | 100 | 97 | 15.4 | 100 | 15.4 |
- This browser only partially implements this feature
- This feature was removed in a later browser version (12.1)
- Even though `window.AbortController` is defined, it doesn't really abort `fetch` requests. See bug 174980.
- This browser only partially implements this feature
- This feature was removed in a later browser version (12.2)
- Even though `window.AbortController` is defined, it doesn't really abort `fetch` requests. See bug 174980.
- This browser only partially implements this feature
- This feature was removed in a later browser version (12.1)
- Even though `window.AbortController` is defined, it doesn't really abort `fetch` requests. See bug 174980.
- This browser only partially implements this feature
- This feature was removed in a later browser version (12.2)
- Even though `window.AbortController` is defined, it doesn't really abort `fetch` requests. See bug 174980.
- This browser only partially implements this feature
- This feature was removed in a later browser version (12.1)
- Even though `window.AbortController` is defined, it doesn't really abort `fetch` requests. See bug 174980.
- This browser only partially implements this feature
- This feature was removed in a later browser version (12.2)
- Even though `window.AbortController` is defined, it doesn't really abort `fetch` requests. See bug 174980.
- This browser only partially implements this feature
- This feature was removed in a later browser version (12.1)
- Even though `window.AbortController` is defined, it doesn't really abort `fetch` requests. See bug 174980.
- This browser only partially implements this feature
- This feature was removed in a later browser version (12.2)
- Even though `window.AbortController` is defined, it doesn't really abort `fetch` requests. See bug 174980.
Use cases
-
Using AbortController and AbortSignal
The AbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired.
Cautions
- May not be supported in older browsers.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.