mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
lib: fix diagnostics_channel hasSubscribers error
Fixes: https://github.com/nodejs/node/issues/36598 PR-URL: https://github.com/nodejs/node/pull/36599 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
317a1d7a0d
commit
08b69fb1e8
2 files changed
+11
-2
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
Reference in new issue
Block a user