diagnostics_channel: add opt-in subscriber suppression via suppressedBy and suppressed()#63651
Open
DivyanshuX9 wants to merge 4 commits into
Open
diagnostics_channel: add opt-in subscriber suppression via suppressedBy and suppressed()#63651DivyanshuX9 wants to merge 4 commits into
DivyanshuX9 wants to merge 4 commits into
Conversation
Defer non-critical warnings to the next event loop iteration when can_call_into_js() returns false. This prevents crashes when V8 emits warnings during REPL preview evaluation or other contexts where JavaScript execution is temporarily forbidden. When a warning is emitted inside DisallowJavascriptExecutionScope, ProcessEmitWarningGeneric cannot be called immediately. Instead, use env->SetImmediate() to queue the warning emission for after the scope exits. This preserves full warning formatting, deprecation codes, and --redirect-warnings routing. Signed-off-by: Divyanshu Sharma <Divyanshu88999@gmail.com>
DivyanshuX9
added a commit
to DivyanshuX9/node
that referenced
this pull request
May 29, 2026
Refs: nodejs#63623 Refs: nodejs#63651 Signed-off-by: Divyanshu Sharma <divyanshu88999@gmail.com>
5b4110a to
8b122c2
Compare
Contributor
Author
Refs: nodejs#63623 Refs: nodejs#63651 Signed-off-by: Divyanshu Sharma <divyanshu88999@gmail.com>
Refs: nodejs#63623 Refs: nodejs#63651 Signed-off-by: Divyanshu Sharma <divyanshu88999@gmail.com>
8b122c2 to
e4aea85
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #63651 +/- ##
==========================================
+ Coverage 90.28% 90.31% +0.03%
==========================================
Files 730 732 +2
Lines 234802 236480 +1678
Branches 43953 44527 +574
==========================================
+ Hits 211991 213580 +1589
- Misses 14530 14612 +82
- Partials 8281 8288 +7
🚀 New features to boost your workflow:
|
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.
Summary
This change moves suppression tracking into the diagnostics channel runtime
using a per-async-context storage so suppression state survives Promise/timer
boundaries. It introduces a lazy AsyncLocalStorage-based context for suppression,
wires per-subscription/store opt-in, and exposes a
suppressed(key, fn, thisArg, ...args)helper that runsfnwith the given suppression key active for thecurrent async context.
What Changed
lib/diagnostics_channel.jsAsyncLocalStoragefor suppression contextwithSuppressionsContext(set, fn, thisArg, args)and
getSuppressionsStorage()suppressed(key, fn, ...)now runsfninside the ALS context sosuppression persists across Promise/async boundaries
ActiveChannel.prototype.subscribeandbindStoreaccept anoptions.suppressedByopt-in and validate key typespublishand store-scoping now check the active suppression set(via
ALS.getStore()) and skip subscribers/stores whosesuppressedBykey is activeTests
test/parallel/test-diagnostics-channel-suppression.jscovering 10 scenarios: sync, async, timer, and store cases
Why
The previous stack-based approach lost suppression state across async
boundaries (Promise and timer continuations). Using
AsyncLocalStoragepreserves suppression state across Promise chains and
microtask/macrotask boundaries while remaining safe to lazily initialize
during bootstrap.
Backward Compatibility
is completely unaffected unless it explicitly uses
suppressedByorcalls
suppressed()unavailable at runtime, the code falls back gracefully to a non-ALS
path with no cross-async persistence, preventing snapshot/bootstrap
failures
suppressedByor callssuppressed()Testing Performed
python tools/test.py parallel/test-diagnostics-channel-suppression.jsmustCallmismatch was observed during debugging (now resolved)Pre-Merge Checklist
console.errordebug logging fromsuppressed()in
diagnostics_channel.jstools/test.py parallel/test-diagnostics-channel-suppression.js—until all tests pass with no harness warnings
test-diagnostics-channel-suppression.js(remove any debug scaffolding used during development)
suppressed(key, fn, thisArg, ...args)subscribe(handler, { suppressedBy })bindStore(als, transform, { suppressedBy })CHANGELOG.mdper repo processverify ALS overhead is acceptable
@nodejs/diagnostics@nodejs/async-hooks