class AbortSignal

Signals abortion to abortable operations such as fetch().

Index

Properties

Methods

aborted boolean read-only

Whether the signal has been aborted.

addEventListener(type, listener)

Registers a listener.

addEventListener(type: string, listener: (...args: any[]) => void): void;
NameTypeDescription
typestringthe event name, typically "abort"
listener(...args: any[]) => voidthe callback to invoke

reason any read-only

The abort reason, when AbortSignal.aborted is true.

removeEventListener(type, listener)

Removes a previously registered listener.

removeEventListener(type: string, listener: (...args: any[]) => void): void;
NameTypeDescription
typestringthe event name
listener(...args: any[]) => voidthe callback to remove

AbortSignal.timeout(ms) static

Returns a signal that aborts automatically after ms milliseconds.

static timeout(ms: number): AbortSignal;
NameTypeDescription
msnumberthe timeout in milliseconds
Return ValueAbortSignal