Skip to content

Add disposer and async_disposer#1488

Draft
jasnell wants to merge 3 commits intowhatwg:mainfrom
jasnell:jasnell-disposer-async-disposer
Draft

Add disposer and async_disposer#1488
jasnell wants to merge 3 commits intowhatwg:mainfrom
jasnell:jasnell-disposer-async-disposer

Conversation

@jasnell
Copy link

@jasnell jasnell commented May 19, 2025

An intial draft at adding the disposer and async_disposer keywords to declare that an interface implements Symbol.dispose and Symbol.asyncDispose:

interface Foo {
  disposer;
  async_disposer;
}
using foo = new Foo();
await using foo = new Foo();
  • At least two implementers are interested (and none opposed):
    • Node.js
    • Cloudflare Workers
    • ...
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
    • Deno: …
    • Node.js: …
    • webidl2.js: …
    • widlparser: …
  • 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

@jasnell
Copy link
Author

jasnell commented May 19, 2025

This is a first attempt at resolving #1459 /cc @annevk

@jasnell
Copy link
Author

jasnell commented May 19, 2025

I'll wait to cleanup the remaining build errors once it is determined whether this will likely move forward or not.

@glatengcatabay-dotcom

This comment was marked as spam.

@dontcallmedom
Copy link
Contributor

is anyone looking at unblocking this?

@saschanaz
Copy link
Member

Failure logs are gone, what kind of error did we have here? Is it still a thing?

@saschanaz
Copy link
Member

saschanaz commented Feb 11, 2026

And should we start with the single-keyword idea? I also agree with @annevk's comment in the issue that async_disposer sounds dedundant.

Edit: But this PR doesn't exactly look like what the issue said. Maybe this is fine.
Edit 2: But do we really want to let specifications only define a disposer without having a named method for that? Having to call foo[Symbol.dispose]() sounds kinda awkward...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants