Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable explicit resource management for JavaScript #28119

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Feb 14, 2025

This commit enabled [explicit resource management]
(https://github.com/tc39/proposal-explicit-resource-management)
proposal for JavaScript code.

This is done by upgrading deno_ast to a version that no longer
transpiles TS files with using keyword, and instead enables
a V8 flag that provides native support.

Closes #20821

@bartlomieju
Copy link
Member Author

bartlomieju commented Feb 14, 2025

Need to land denoland/deno_ast#290 first and add a test that uses using keyword in a JS file.

@lucacasonato lucacasonato changed the title feat: Enable explicit resource management for JavaScript feat: enable explicit resource management for JavaScript Feb 14, 2025
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lucacasonato
Copy link
Member

We can't land this - V8 does not call the dispose method with the correct receiver when await using falls back to [Symbol.dispose]: (async () => { await using foo = { [Symbol.dispose]() { console.log(this, "asd") }, foo: "bar" }})(). I file a V8 bug and ask them to hold this (ie not ship in Chrome 134.

@0f-0b
Copy link
Contributor

0f-0b commented Feb 15, 2025

Just tested this branch and found another bug where a top-level await using crashes the process.

console.log("before await using");
await using _ = {
  [Symbol.dispose]() {
    console.log("dispose");
  },
};
console.log("after await using");

@lucacasonato
Copy link
Member

@bartlomieju bartlomieju added this to the 2.3.0 milestone Feb 18, 2025
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.

DisposableStack is not implemented
5 participants