node
node copied to clipboard
fs, stream: add initial `Symbol.dispose` and `Symbol.asyncDispose` support
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]
Review requested:
- [ ] @nodejs/streams
Q: Does
await using
fallback toSymbol.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
@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.
CI: https://ci.nodejs.org/job/node-test-pull-request/52351/
CI: https://ci.nodejs.org/job/node-test-pull-request/52432/
CI: https://ci.nodejs.org/job/node-test-pull-request/52440/
CI: https://ci.nodejs.org/job/node-test-pull-request/52453/
CI: https://ci.nodejs.org/job/node-test-pull-request/52456/
Landed in 71d770779241d9be8f67988319809b6748b03ba4
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.
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.
This commit does not land cleanly on v18.x-staging
and will need manual backport in case we want it in v18.