[13.5] Bug in explicit resource management?

31 views
Skip to first unread message

ClearScript Developers

unread,
Apr 23, 2025, 11:44:49 AM4/23/25
to v8-dev
Hello!

Consider the following:

async function foo() {
    await using x = { [Symbol.asyncDispose]: 0, [Symbol.dispose]: () => {} };
}
await foo();

This throws "TypeError: Symbol(Symbol.asyncDispose) is not a function".

Is that a bug? According to our reading of the proposal, the synchronous fallback should be used if [Symbol.asyncDispose] exists but isn't a function. From the proposal:

let $$dispose = x[Symbol.asyncDispose];
if (typeof $$dispose !== "function") {
  $$dispose = x[Symbol.dispose];
}

Thanks!

Marja Hölttä

unread,
Apr 23, 2025, 1:04:26 PM4/23/25
to v8-...@googlegroups.com, Rezvan Mahdavi Hezaveh
cc rezvan

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/v8-dev/41a93f7b-1ea5-49f7-b0d1-87445a3e2493n%40googlegroups.com.


--


Google Germany GmbH

Erika-Mann-Straße 33

80636 München


Geschäftsführer: Paul Manicle, Liana Sebastian.

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg


Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde.

    

This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.

Rezvan Mahdavi Hezaveh

unread,
Apr 23, 2025, 1:31:42 PM4/23/25
to v8-...@googlegroups.com, clearsc...@gmail.com, Marja Hölttä, Shu-yu Guo
Hi,

We followed spec text to implement the feature. According to that:

GetDisposeMethod
... 
a. Let method be ? GetMethod(V, @@asyncDispose).
b. If method is undefined, then
      i. Set method to ? GetMethod(V, @@dispose).

So when the [Symbol.asyncDispose] is defined, [Symbol.dispose] will not be used. I am not sure why the description in the Github repository is not consistent with the spec text.

Please let me know if you have any other questions!
Bests,
Rezvan

ClearScript Developers

unread,
Apr 23, 2025, 3:09:41 PM4/23/25
to v8-dev

Hi Rezvan,

You're absolutely right. We'd assumed that the GitHub repository was authoritative.

Thank you!
Reply all
Reply to author
Forward
0 new messages