GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — diagnostics_channel: fix last subscriber removal · nodejs/node@114e088

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • diagnostics_channel.js
  • test/parallel
    • test-diagnostics-channel-sync-unsubscribe.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/diagnostics_channel.js‎

Copy file name to clipboardExpand all lines: lib/diagnostics_channel.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class ActiveChannel {
136136
}
137137

138138
publish(data) {
139-
for (let i = 0; i < this._subscribers.length; i++) {
139+
for (let i = 0; i < (this._subscribers?.length || 0); i++) {
140140
try {
141141
const onMessage = this._subscribers[i];
142142
onMessage(data, this.name);
Collapse file

‎test/parallel/test-diagnostics-channel-sync-unsubscribe.js‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const dc = require('node:diagnostics_channel');
5+
6+
const channel_name = 'test:channel';
7+
const published_data = 'some message';
8+
9+
const onMessageHandler = common.mustCall(() => dc.unsubscribe(channel_name, onMessageHandler));
10+
11+
dc.subscribe(channel_name, onMessageHandler);
12+
13+
// This must not throw.
14+
dc.channel(channel_name).publish(published_data);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.