AbortSignal.abort() is a static method that allows creating a new AbortSignal object that is already aborted. It is similar in spirit to Promise.reject(), and provides improved developer ergonomics.

Motivation

Web developers have found aborted AbortSignal objects to be useful for a variety of purposes. It signifies to JavaScript APIs that no work should be done. However currently, creating an already-aborted AbortSignal object requires jumping through quite a few hoops: const controller = new AbortController(); controller.abort(); return controller.signal; A new AbortSignal.abort() factory function simplifies this to just return AbortSignal.abort();

Specification

Established standard

Status in Chromium

Blink>DOM


Enabled by default (tracking bug) in:

  • Chrome for desktop release 93
  • Chrome for Android release 93
  • Android WebView release 93

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.

Owner

Intent to Prototype url

Intent to Prototype thread

Search tags

AbortSignal,

Last updated on 2021-06-22