GeezerVison is showing github.com — diagnostics_channel: validate before channel activation · nodejs/node@755c2cf
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/diagnostics_channel.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -205,6 +205,7 @@ class Channel { |
205 | 205 | } |
206 | 206 |
|
207 | 207 | subscribe(subscription) { |
| 208 | + validateFunction(subscription, 'subscription'); |
208 | 209 | markActive(this); |
209 | 210 | this.subscribe(subscription); |
210 | 211 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-diagnostics-channel-object-channel-pub-sub.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,3 +44,5 @@ assert.ok(!channel.unsubscribe(subscriber)); |
44 | 44 | assert.throws(() => { |
45 | 45 | channel.subscribe(null); |
46 | 46 | }, { code: 'ERR_INVALID_ARG_TYPE' }); |
| 47 | +assert.ok(!channel.hasSubscribers); |
| 48 | +assert.ok(!dc.hasSubscribers('test')); |
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-diagnostics-channel-pub-sub.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,6 +42,8 @@ assert.ok(!dc.unsubscribe(name, subscriber)); |
42 | 42 | assert.throws(() => { |
43 | 43 | dc.subscribe(name, null); |
44 | 44 | }, { code: 'ERR_INVALID_ARG_TYPE' }); |
| 45 | +assert.ok(!channel.hasSubscribers); |
| 46 | +assert.ok(!dc.hasSubscribers(name)); |
45 | 47 |
|
46 | 48 | // Reaching zero subscribers should not delete from the channels map as there |
47 | 49 | // will be no more weakref to incRef if another subscribe happens while the |
|