diff --git a/lib/diagnostics_channel.js b/lib/diagnostics_channel.js index 0a3552dc975040..c29c9ff0052405 100644 --- a/lib/diagnostics_channel.js +++ b/lib/diagnostics_channel.js @@ -8,7 +8,6 @@ const { ObjectGetPrototypeOf, ObjectSetPrototypeOf, SymbolHasInstance, - WeakRefPrototypeGet } = primordials; const { @@ -107,7 +106,7 @@ function channel(name) { function hasSubscribers(name) { let channel; const ref = channels[name]; - if (ref) channel = WeakRefPrototypeGet(ref); + if (ref) channel = ref.get(); if (!channel) { return false; } diff --git a/test/parallel/test-diagnostics-channel-has-subscribers.js b/test/parallel/test-diagnostics-channel-has-subscribers.js new file mode 100644 index 00000000000000..de37267555089e --- /dev/null +++ b/test/parallel/test-diagnostics-channel-has-subscribers.js @@ -0,0 +1,10 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const { channel, hasSubscribers } = require('diagnostics_channel'); + +const dc = channel('test'); +assert.ok(!hasSubscribers('test')); + +dc.subscribe(() => {}); +assert.ok(hasSubscribers('test'));