Skip to content

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
@bartlomieju
Copy link
Member Author

listenerExplicitResourceManagement test is actually wrong - it should be removed.

@aidenlx
Copy link

aidenlx commented Mar 21, 2025

Great news, v8 official support for explicit resource management landed with chrome 134 🎉

Explicit resource management (async)
Tracking bug #42203814 | ChromeStatus.com entry

Explicit resource management (sync)
Tracking bug #42203506 | ChromeStatus.com entry

@bartlomieju bartlomieju requested a review from lucacasonato April 8, 2025 07:34
Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

This still needs the deno_ast upgrade

@dsherret dsherret merged commit c8291e6 into denoland:main Apr 8, 2025
18 checks passed
@dsherret
Copy link
Member

dsherret commented Apr 8, 2025

Should have renamed this one as fix because we should land it in a patch release because swc's transform has lots of bugs for this. I'll land the deno_ast change in a follow-up PR.

nathanwhit pushed a commit that referenced this pull request Apr 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

---------

Co-authored-by: Luca Casonato <hello@lcas.dev>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
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
6 participants