| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d4398d4 commit 114e088
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,7 +136,7 @@ class ActiveChannel { | |||
| 136 | 136 | } | |
| 137 | 137 | ||
| 138 | 138 | publish(data) { | |
| 139 | - for (let i = 0; i < this._subscribers.length; i++) { | ||
| 139 | + for (let i = 0; i < (this._subscribers?.length || 0); i++) { | ||
| 140 | 140 | try { | |
| 141 | 141 | const onMessage = this._subscribers[i]; | |
| 142 | 142 | onMessage(data, this.name); | |
| Original file line number | Diff line number | Diff 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); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments