Repository navigation
fix(ext/node): validate a diagnostics_channel subscription before activation - #35
Merged
jackspirou merged 1 commit intoSep 24, 2026
Conversation
…ivation Channel#subscribe() activated the channel before it validated the subscription. An invalid subscription threw ERR_INVALID_ARG_TYPE, but the channel stayed active, so hasSubscribers returned true without a subscriber. Validate first, as nodejs/node#65313 does.
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
Channel#subscribe()on an inactive channel calledmarkActive()before it validated the subscription. An invalid subscription threwERR_INVALID_ARG_TYPE, but the channel stayed active. After that,channel.hasSubscribersanddiagnostics_channel.hasSubscribers(name)returnedtruewith no subscriber.Node.js fixed the same bug in nodejs/node#65313 (issue nodejs/node#65312), shipped in v24.21.0 and v26.8.0. The Node.js 24.21+ and 26.8+ versions of
test-diagnostics-channel-pub-sub.jsandtest-diagnostics-channel-object-channel-pub-sub.jsassert this behavior.Change
Channel#subscribe()callsvalidateFunction(subscription, "subscription")beforemarkActive(this).tests/unit_node/diagnostics_channel_test.ts. It coversdc.subscribe(name, null)andchannel.subscribe(null), and then a valid subscribe and unsubscribe.No Node.js release depends on the old behavior, so this is a plain bug fix with no version policy.
Tests
AssertionError) and passes after it.unit_node::diagnostics_channel_test: pass.node_compat:test-diagnostics-channel-pub-sub.jsandtest-diagnostics-channel-object-channel-pub-sub.jspass.tools/lint.js --js: clean.