Skip to content

feat(runtime): AbortController, AbortSignal, EventTarget and DOMException - #42

Merged
triniwiz merged 1 commit into
mainfrom
feat/web-events-abort-controller
Nov 6, 2026
Merged

triniwiz merged 1 commit into
mainfrom
feat/web-events-abort-controller

Conversation

@triniwiz

@triniwiz triniwiz commented Nov 6, 2026

Copy link
Copy Markdown
Member

Nothing provided these globals, so new AbortController() threw a ReferenceError, and APIs that take an AbortSignal had to accept duck-typed objects.

Changes

New runtime/src/js/events.js installs DOMException, Event, CustomEvent, EventTarget, AbortSignal and AbortController. It runs on both engines, next to crypto.js, and installs each global only when it's missing.

  • EventTarget: addEventListener options once, capture, passive and signal; handleEvent objects; duplicate registrations ignored; stopImmediatePropagation; preventDefault on cancelable events. A throwing listener is reported asynchronously and doesn't stop the others.
  • AbortSignal: aborted, reason, onabort, throwIfAborted(), plus the static abort(), timeout(ms) and any(signals).
    • Default reasons are DOMExceptions (AbortError, TimeoutError).
    • any() flattens composites, and every affected signal is aborted before the first abort event fires.
    • A timeout() signal is held weakly by its timer, with a FinalizationRegistry cancelling the timer. Composites and timeout signals are kept alive only while something listens for their abort.
  • DOMException: name/message/code, the legacy code constants, instanceof Error.

It's written with plain functions and WeakMap state (no classes or private fields), so Hermes and QuickJS can run it.

Testing

The same 26-check script ran on every engine below. On Node, it first deletes Node's own globals, so it checks this implementation, and it also passes against Node's native ones.

engine result
classic V8 26/26, synchronous checks only: the test runner has no event loop, so timeout() isn't fired
QuickJS standalone host 26/26, including timeout() firing
Node with its own implementations removed 26/26
Node's native implementations 26/26

…tion

Adds DOMException, Event, CustomEvent, EventTarget, AbortSignal (with
abort, timeout and any, onabort, throwIfAborted) and AbortController as
globals on every engine; each is installed only when the global is
missing. Nothing provided them before, so `new AbortController()` threw
a ReferenceError and cancellation APIs had to take duck-typed signals.

addEventListener supports once, capture, passive and signal. A timeout
signal is held weakly by its timer, and composites from any() stay
reachable only while something listens for their abort.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 63c5dee0-5aad-412d-b65c-c04964add3c9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@triniwiz
triniwiz merged commit e0ca9b0 into main Nov 6, 2026
3 checks passed
@triniwiz
triniwiz deleted the feat/web-events-abort-controller branch November 6, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant