[whatwg/dom] Add abortSignal.addAbortCallback (PR #1425)

This PR is a discussion starter. The goals:

- Make progress on allowing TC39 able to adopt/use `AbortController` and `AbortSignal` without requiring `Event` and `EventTarget`.
- Provide a system where abort 'listeners' can be GC'd as soon as abort has happened.

The behaviour in this PR means that abort reactions in userland and the web platform interleave. @bakkot is keen on this. I'm a little unsure, so I'm interested in more opinions.

I'm a little worried about:

```js
const controller = new AbortController();
const signal = controller.signal;

let thing;

signal.addAbortCallback(() => {
  console.log(thing.running);
  // The above is unexpectedly true,
  // because the platform's steps to set it to false haven't run yet.
});

thing = doThing(signal);
controller.abort();
```

But maybe this already happens with promises?

---

- [ ] At least two implementers are interested (and none opposed):
   * …
   * …
- [ ] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
   * … <!-- If these tests are tentative, link a PR to make them non-tentative. -->
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
   * Chromium: …
   * Gecko: …
   * WebKit: …
   * Deno (only for aborting and events): …
   * Node.js (only for aborting and events): …
- [ ] [MDN issue](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) is filed: …
- [ ] The top of this comment includes a [clear commit message](https://github.com/whatwg/meta/blob/main/COMMITTING.md) to use. <!-- If you created this PR from a single commit, Github copied its message. Otherwise, you need to add a commit message yourself. -->

(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)

You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/dom/pull/1425

-- Commit Summary --

  * Add abortSignal.addAbortCallback

-- File Changes --

    M dom.bs (21)

-- Patch Links --

https://github.com/whatwg/dom/pull/1425.patch
https://github.com/whatwg/dom/pull/1425.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1425
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/pull/1425@github.com>

Received on Thursday, 20 November 2025 05:23:09 UTC