Skip to content

DOM abort

How Elide supports AbortController and AbortSignal per the DOM Standard, including abort(), any() and timeout(), and signals for fetch, timers and streams.

On this page

AbortController and AbortSignal are globals and follow the DOM Standard, including AbortSignal.abort(), AbortSignal.any(), AbortSignal.timeout(), and the signal option of addEventListener. Fetch, timers, and streams accept a signal.

Example

js
// abort.mjs
const controller = new AbortController();
controller.signal.addEventListener("abort", () => console.log("aborted:", controller.signal.reason));
controller.abort("user cancelled");

const timeout = AbortSignal.timeout(10);
await new Promise((resolve) => timeout.addEventListener("abort", resolve));
console.log(timeout.reason.name);

const either = AbortSignal.any([new AbortController().signal, AbortSignal.abort("first")]);
console.log(either.aborted, either.reason);
utf-8 · js · Lines: 11

elide run abort.mjs prints:

text
aborted: user cancelled
TimeoutError
true first
utf-8 · text · Lines: 3

Reference

Status: Full · Not measured · since 1.1.0

Exports

ExportKindStatusNotes
AbortControllerclassFullsignal, abort()
AbortSignalclassFullAbortSignal.abort(), AbortSignal.timeout(), AbortSignal.any(), aborted, reason, throwIfAborted(), onabort

Was this page helpful?