diagnostics_channel: validate before channel activation · nodejs/node@d286423 · GitHub
Skip to content

Commit d286423

Browse files
trivikraduh95
authored andcommitted
diagnostics_channel: validate before channel activation
Validate the first subscription before calling markActive(). This prevents invalid callbacks from leaving channels active and notifying native consumers without an installed subscriber. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: codex:gpt-5.6-sol PR-URL: #65313 Fixes: #65312 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent 65f6750 commit d286423

3 files changed

Lines changed: 5 additions & 0 deletions

File tree

lib/diagnostics_channel.js

Lines changed: 1 addition & 0 deletions

test/parallel/test-diagnostics-channel-object-channel-pub-sub.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ assert.ok(!channel.unsubscribe(subscriber));
4444
assert.throws(() => {
4545
channel.subscribe(null);
4646
}, { code: 'ERR_INVALID_ARG_TYPE' });
47+
assert.ok(!channel.hasSubscribers);
48+
assert.ok(!dc.hasSubscribers('test'));

test/parallel/test-diagnostics-channel-pub-sub.js

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)