Skip to content

AbortSignal: abort event ​

The abort event fires when the signal is aborted.

Syntax ​

signal.addEventListener('abort', (event) => { })

Event object ​

Event, with only type and target. Not cancelable.

When it fires ​

When the event fires, aborted is already true and reason already has a value.

Examples ​

js
const controller = new AbortController();
controller.signal.addEventListener('abort', () => {
  console.log('aborted', controller.signal.aborted);
});
controller.abort();

Result: Prints aborted true.

Differences from the web ​

There is no onabort property; listen only with addEventListener().

See also ​