← Back to release summary

AbortSignal.prototype.throwIfAborted

Category
DOM
Type
Chromium catches up
Status
Enabled by default (Chrome 100)
Intent stage
Shipped

WPT details: https://wpt.fyi/results/dom/abort/event.any.html?label=master&label=experimental&aligned&q=dom%2Fabort

Summary

Throws an AbortSignal's reason if the signal is aborted. This convenience method can be used by signal-handling functions to check a signal's abort status and propagate the abort reason, e.g. after async operations that might change a signal's state.

Motivation

AbortSignal-handling functions often need to check the signal's status and propagate the error if the signal has been aborted. AbortSignal.throwIfAborted provides a convenient and consistent way to do this.

Standards & signals

Ecosystem

Samples: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted#examples

View on chromestatus.com