diagnostics_channel: replace using with try-finally#64251
diagnostics_channel: replace using with try-finally#64251ayush23chaudhary wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the experimental using syntax from lib/diagnostics_channel.js, replacing it with equivalent try...finally disposal to avoid crashes when Node is run with --no-js-explicit-resource-management.
Changes:
- Replaced
usingstatements with explicittry...finallyblocks that invoke[SymbolDispose](). - Updated scope handling in
ActiveChannel,BoundedChannel, andTracingChannelpaths to ensure disposal occurs reliably without relying on flagged syntax.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
548c1c1 to
1d66ae6
Compare
|
Thanks for the thorough review, @Renegade334 and @anonrig!
|
Renegade334
left a comment
There was a problem hiding this comment.
Thanks for your changes! Some more comments 👍
1d66ae6 to
6f2d7cc
Compare
|
|
LGTM, but please run |
6f2d7cc to
d7d9082
Compare
|
Thanks for the LGTM! I ran make |
d7d9082 to
0be0ec6
Compare
Qard
left a comment
There was a problem hiding this comment.
One minor nit but otherwise LGTM.
Signed-off-by: Ayush Chaudhary <ayush23chaudhary@gmail.com>
0be0ec6 to
50b7999
Compare
jasnell
left a comment
There was a problem hiding this comment.
I'm -1 on moving away from using. It's stage 4 at this point. I'd rather we forbid the option that allows it to be turned off than not use it.
|
Hi @jasnell, thanks for commenting Since @Renegade334, @anonrig, and @Qard previously reviewed and approved this try-finally refactor to resolve #64230, it seems like there is a difference in philosophy on how Node core should handle the --no-js-explicit-resource-management flag now that ERM is Stage 4. I am more than happy to pivot and take a different approach (like opening a PR to forbid the flag instead, if that is the preferred direction). I will pause my work here and let you all reach a consensus on the best path forward for the project. Just let me know what the final decision is, and I'll be happy to execute it. |
|
I'm fine either way. There's not much use of ERM in core yet, only exposing as an API surface. In my opinion, needing to use the try/finally form is not much more than a minor annoyance. An argument could be made that no longer functioning with that flag should make the introduction of ERM use a semver-major. We could allow this change and then follow up with restoring ERM and calling it a semver-major. 🤔 |
Fixes: #64230
Description
This PR replaces instances of the experimental
usingsyntax withtry...finallyblocks insidelib/diagnostics_channel.js.Since Explicit Resource Management is still a flagged feature in V8, encountering
usingin core causes a segfault when running Node with the--no-js-explicit-resource-managementflag. This refactor maintains the exact same resource cleanup semantics by manually calling[SymbolDispose]()in afinallyblock, avoiding the flagged syntax entirely.Example of Refactor
Before:
After