Skip to content

Conversation

@jakearchibald
Copy link
Collaborator

@jakearchibald jakearchibald commented Nov 20, 2025

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:

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 are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
    • Deno (only for aborting and events): …
    • Node.js (only for aborting and events): …
  • MDN issue is filed: …
  • The top of this comment includes a clear commit message to use.

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

@bakkot
Copy link

bakkot commented Nov 20, 2025

With regards to the example, the way a user is actually likely to run into this is more like

import { operation } from 'some-framework';

async function whatever(signal) {
  await Promise.all([
    builtin1({ signal }),
    operation({ signal }),
    builtin2({ signal }),
  ]);
}

From the user's perspective, it is very strange if these are aborted in anything other than LIFO or FIFO order. Users are not (and should not be) reasoning about whether the operations they're calling are defined in their framework or in the platform, and there is no way to understand the builtin1, builtin2, operation order without such reasoning.

@annevk annevk added needs implementer interest Moving the issue forward requires implementers to express interest addition/proposal New features or enhancements topic: aborting AbortController and AbortSignal labels Nov 20, 2025
@jakearchibald
Copy link
Collaborator Author

That example is pretty compelling.

@saschanaz
Copy link
Member

I'd like the design to allow #1389 in the future 👀 (doesn't seem to block it right now, which is cool)

@jakearchibald jakearchibald added the agenda+ To be discussed at a triage meeting label Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition/proposal New features or enhancements agenda+ To be discussed at a triage meeting needs implementer interest Moving the issue forward requires implementers to express interest topic: aborting AbortController and AbortSignal

Development

Successfully merging this pull request may close these issues.

5 participants