AbortSignal.any(signals) returns a signal that is aborted when any of the source signals are aborted. Developers can use this to combine independent abort sources, e.g. timeouts specified with AbortSignal.timeout() and signals associated with user input, and pass them to async APIs like fetch().

Motivation

Some async operations may be aborted due to a variety of reasons, e.g. due to timeout or user cancellation. And while nothing prevents an AbortController's abort method from being invoked for multiple reasons, combining signals enables separate layers of control, where the scope of cancellation may vary. Since AbortSignal-accepting APIs only accept a single signal, combining signals currently needs to be done in userland using event listeners, but this is complicated by challenges around memory leaks. AbortSignal.any() makes it easy to combine signals, and by allowing the UA to maintain these relationships, the UA can free related resources when safe to do so.

Status in Chromium

Blink>DOM


No active development (tracking bug)

Consensus & Standardization

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

  • No signal
  • No signal
  • No signals

Owner

Last updated on 2022-05-06