diagnostics_channel: replace using with try-finally#64251
Open
ayush23chaudhary wants to merge 2 commits into
Open
diagnostics_channel: replace using with try-finally#64251ayush23chaudhary wants to merge 2 commits into
ayush23chaudhary wants to merge 2 commits 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.
Renegade334
reviewed
Jul 2, 2026
| triggerUncaughtException(err, false); | ||
| }); | ||
| continue; | ||
| const stack = new DisposableStack(); |
Member
There was a problem hiding this comment.
DisposableStack is also a flagged global.
Author
There was a problem hiding this comment.
@Renegade334, I did not realize DisposableStack was part of the same flagged feature. I've replaced it with a standard array that manually iterates in reverse during disposal. Just pushed the update.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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