Home

AbortError

AbortError is an error type used in web platform APIs to signal that an operation was canceled. It is represented as a DOMException with the name AbortError. The message is often "The operation was aborted," but implementations may vary.

The cancellation mechanism relies on AbortController and AbortSignal. An AbortController instance provides a signal that can

In practice, fetch will reject its promise with an AbortError when the request is aborted via the

Handling AbortError typically involves catching the error and distinguishing it from other failures. A common pattern

Notes and caveats: AbortError is not necessarily fatal; it indicates deliberate cancellation. Support for AbortController and

See also: AbortController, AbortSignal, DOMException, Fetch API, cancellation patterns in asynchronous JavaScript.

be
passed
to
asynchronous
APIs
such
as
fetch,
ReadableStream,
or
WebCrypto
operations.
Calling
abort()
on
the
controller
triggers
cancellation
of
the
associated
operation,
causing
it
to
reject
or
throw
an
AbortError.
signal.
Other
APIs
that
honor
the
signal
may
also
throw
or
reject
with
AbortError,
depending
on
the
operation
and
environment.
is
to
check
the
error
name—if
err.name
is
"AbortError,"
the
cancellation
can
be
treated
as
a
normal
control
flow
event
rather
than
a
failure,
while
other
errors
are
handled
separately.
AbortSignal
is
widespread
in
modern
browsers
and
in
many
JavaScript
environments,
but
older
environments
may
lack
this
mechanism,
in
which
case
cancellation
may
be
implemented
differently
or
not
at
all.
Some
libraries
may
polyfill
AbortController,
producing
a
DOMException
with
the
AbortError
name
to
maintain
a
consistent
interface.