Skip to content

Commit d20235b

Browse files
Lxxyxdanielleadams
authored andcommitted
lib: fix diagnostics_channel hasSubscribers error
Fixes: #36598 PR-URL: #36599 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 93237c5 commit d20235b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/diagnostics_channel.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const {
88
ObjectGetPrototypeOf,
99
ObjectSetPrototypeOf,
1010
SymbolHasInstance,
11-
WeakRefPrototypeGet
1211
} = primordials;
1312

1413
const {
@@ -107,7 +106,7 @@ function channel(name) {
107106
function hasSubscribers(name) {
108107
let channel;
109108
const ref = channels[name];
110-
if (ref) channel = WeakRefPrototypeGet(ref);
109+
if (ref) channel = ref.get();
111110
if (!channel) {
112111
return false;
113112
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const { channel, hasSubscribers } = require('diagnostics_channel');
5+
6+
const dc = channel('test');
7+
assert.ok(!hasSubscribers('test'));
8+
9+
dc.subscribe(() => {});
10+
assert.ok(hasSubscribers('test'));

0 commit comments

Comments
 (0)