Globals

AbortSignal.abort()

Creates a signal that is already aborted. Use it when an operation should not start, including tests for early cancellation. A signal is single-use; an aborted signal does not reset to active. Tested on Node.js 22.16.0. Example output (one line per entry): ["true closed"].

Formal Syntax & Structure

nodejs syntaxnodejs
AbortSignal.abort([reason])

Parameters & Attributes

NameTypeDescription
reasonanyReason exposed on the signal.

Return Value

AbortSignal

Already-aborted signal.

Working Example

Example Snippetnodejs
const signal = AbortSignal.abort(new Error('closed'));console.log(signal.aborted, signal.reason.message);
Node.js Reference