AbortSignal: cancel fetch and other ongoing work
Answer: AbortController provides an abort() method that toggles the state of a corresponding AbortSignal. Fetch can take an AbortSignal. If no abort reason is given, an AbortError DOMException is stored.
The controller and signal
Meet the AbortController and AbortSignal. Read signal from the controller.
The controller only has one method: abort(). When you do this, it notifies the signal.
The DOM standard provides this API. It stays deliberately generic so other web standards and libraries can adopt it.
Fetch can take an AbortSignal.
One pattern is to abort() from a timer so a fetch times out after 5 seconds.
Calling abort() after a completed fetch is ok; fetch simply ignores it.
What the DOM standard requires
Promises lack a built-in aborting mechanism, yet many APIs that use them still need abort semantics.
To cover that gap, AbortController supplies abort(), which toggles the state of a corresponding AbortSignal object.
An API can accept an AbortSignal object, and use its state to determine how to proceed.
new AbortController() yields a controller whose signal is a newly created AbortSignal object.
If reason is undefined, then an AbortError DOMException will be stored.
AbortSignal.any(signals) returns an instance which will be aborted once any of those signals is aborted.
See also
Claims
- id: C1 claim: Fetch can take an AbortSignal. source: S1 evidence: "Fetch can take an AbortSignal"
- id: C2 claim: The controller only has one method, abort(). source: S1 evidence: "The controller only has one method"
- id: C3 claim: abort() toggles the state of a corresponding AbortSignal. source: S2 evidence: "toggles the state of a corresponding AbortSignal"
- id: C4 claim: If reason is undefined, an AbortError DOMException is stored. source: S2 evidence: "an \" AbortError \" DOMException will be stored"
- id: C5 claim: AbortSignal.any() aborts when any of the given signals aborts. source: S2 evidence: "aborted once any of signals is aborted"
Sources
- [S1] Abortable fetch. Chrome Developers. https://developer.chrome.com/blog/abortable-fetch . License: CC-BY-4.0. Accessed 2026-11-23.
- [S2] DOM Living Standard, Aborting ongoing activities. WHATWG. https://dom.spec.whatwg.org/#aborting-ongoing-activities . License: CC-BY-4.0. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Chrome Developers, Abortable fetch; WHATWG, DOM Living Standard, Aborting ongoing activities. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC. CC-BY-4.0 (https://raw.githubusercontent.com/whatwg/fetch/main/LICENSE). Copyright WHATWG contributors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Chrome Developers, Abortable fetch; WHATWG, DOM Living Standard, Aborting ongoing activities. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC. CC-BY-4.0 (https://raw.githubusercontent.com/whatwg/fetch/main/LICENSE). Copyright WHATWG contributors.
Cite this
iinventedlight. 2026. "AbortSignal: cancel fetch and other ongoing work." iinventedlight Library, iil:note:s8dv25w0, version of 2026-11-23. https://iinventedlight.com/library/notes/javascript-abort-signal/. License: CC-BY-4.0.
@misc{iil_note_s8dv25w0,
author = {{iinventedlight}},
title = {{AbortSignal: cancel fetch and other ongoing work}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/javascript-abort-signal/},
note = {Permanent ID iil:note:s8dv25w0. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- javascript-abort-signal.schema.json (schema; CC-BY-4.0)
- javascript-abort-signal.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/javascript-abort-signal.md.