KITFORMA · EDITORIAL GUIDE
How do I cancel a Node fetch request when its time budget expires?
KitForma editorial guide. A request without an explicit deadline can outlive the work that needed it. Cancellation should be passed into the operation rather than implemented only as a competing timer.
Step-by-step guidance
import assert from 'node:assert/strict';
import { setTimeout as delay } from 'node:timers/promises';
const controller = new AbortController();
const pending = delay(1000, 'done', { signal: controller.signal });
controller.abort();
await assert.rejects(pending, { name: 'AbortError' });
// Local cancellation test; it does not assert remote server rollback.Sources and verification
Sources checked:
Scope: This editorial guide is based on the cited sources and tool behavior. A forum question or a query observed for our site does not establish market search volume, low competition, guaranteed rankings or inadequate answers elsewhere.
This starter guide was prepared by KitForma with AI assistance. It is not presented as a real member question or an independent user review. Check the sources and the result with your own file; report corrections in the discussion.