← All notes

Node.js AbortController - cancel fetch, timeouts and other async work

Answer: AbortController is a utility class used to signal cancelation in selected Promise-based APIs. abortController.abort([reason]) triggers the abort signal. AbortSignal.timeout(delay) waits the given number of milliseconds and then aborts.

Examples

const controller = new AbortController();
setTimeout(() => controller.abort(new Error('gave up')), 5_000);

const res = await fetch('https://example.com', { signal: controller.signal });

const timed = AbortSignal.timeout(1_000);
await fetch('https://example.com', { signal: timed });

const combined = AbortSignal.any([controller.signal, AbortSignal.timeout(2_000)]);

Rules

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Node.js API docs, Global objects; nodejs/node (GitHub), doc/api/globals.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Node.js API docs, Global objects; nodejs/node (GitHub), doc/api/globals.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors.

Cite this

Permanent ID: iil:note:x6r1nkp7

iinventedlight. 2026. "Node.js AbortController - cancel fetch, timeouts and other async work." iinventedlight Library, iil:note:x6r1nkp7, version of 2026-11-18. https://iinventedlight.com/library/notes/node-abort-controller/. License: CC-BY-4.0.

@misc{iil_note_x6r1nkp7,
  author = {{iinventedlight}},
  title = {{Node.js AbortController - cancel fetch, timeouts and other async work}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/node-abort-controller/},
  note = {Permanent ID iil:note:x6r1nkp7. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/node-abort-controller.md.