node icon indicating copy to clipboard operation
node copied to clipboard

fs, stream: add initial `Symbol.dispose` and `Symbol.asyncDispose` support

Open MoLow opened this issue 1 year ago • 4 comments

Both TypeScript and Bable already support using (explicit resource management proposal), adding this to node will be convenient

Co-authored-by: Benjamin Gruenbaum [email protected]

MoLow avatar Jun 22 '23 09:06 MoLow

Review requested:

  • [ ] @nodejs/streams

nodejs-github-bot avatar Jun 22 '23 09:06 nodejs-github-bot

Q: Does await using fallback to Symbol.dispose if the async version doesn't exist?

according to this it does: https://github.com/tc39/proposal-explicit-resource-management#await-using-declarations-with-explicit-local-bindings

MoLow avatar Jun 22 '23 09:06 MoLow

@ronag

Implement for stream.Writable as well?

Yeah, and for a lot of other things (http.Server etc), the idea here was to add the symbols and one example so we can distribute the work like we did last year with iterator-helpers.

benjamingr avatar Jun 22 '23 09:06 benjamingr

CI: https://ci.nodejs.org/job/node-test-pull-request/52351/

nodejs-github-bot avatar Jun 22 '23 16:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/52432/

nodejs-github-bot avatar Jun 24 '23 18:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/52440/

nodejs-github-bot avatar Jun 24 '23 21:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/52453/

nodejs-github-bot avatar Jun 25 '23 08:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/52456/

nodejs-github-bot avatar Jun 25 '23 10:06 nodejs-github-bot

Landed in 71d770779241d9be8f67988319809b6748b03ba4

nodejs-github-bot avatar Jun 25 '23 11:06 nodejs-github-bot

The https://github.com/nodejs/node/labels/notable-change label has been added by @benjamingr.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment.

github-actions[bot] avatar Jun 26 '23 06:06 github-actions[bot]

The notable-change PRs with changes that should be highlighted in changelogs.label has been added by @benjamingr.

Node is adding support to the explicit resource management proposal to its resources allowing users of TypeScript/babel to use using/await using with V8 support for everyone else on the way.

benjamingr avatar Jun 26 '23 06:06 benjamingr

This commit does not land cleanly on v18.x-staging and will need manual backport in case we want it in v18.

ruyadorno avatar Sep 10 '23 03:09 ruyadorno