Skip to content

Comments

[WIP] diagnostics_channel: add meta buil-in channels#61943

Draft
simon-id wants to merge 1 commit intonodejs:mainfrom
simon-id:master
Draft

[WIP] diagnostics_channel: add meta buil-in channels#61943
simon-id wants to merge 1 commit intonodejs:mainfrom
simon-id:master

Conversation

@simon-id
Copy link
Contributor

What

This add DC (diagnostics_channel) built-in events, for DC itself. Just like http, console, or process, have built-in events that can be subscribed to, to monitor code, this make it possible for DC to be monitored through DC.

Why

It appeared that multiple people working with DC channels extensively ended up monkey-patching DC in their test app or test suite, to allow some actions to be logged. Now instead of monkey-patching, they can just listen to these events.

It also allows one to create a kind of "dead-letter queue" DC subscription, that will catch all events that were not delivered:

dc.subscribe('diagnostics_channel.publish', ({ channel, data }) => {
  if (channel.hasSubscribers === false) {
    // handle undelivered event
  }
})

Signed-off-by: simon-id <simon.id@protonmail.com>
@nodejs-github-bot nodejs-github-bot added diagnostics_channel Issues and PRs related to diagnostics channel needs-ci PRs that need a full CI run. labels Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diagnostics_channel Issues and PRs related to diagnostics channel needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants