X Tutup
The Wayback Machine - https://web.archive.org/web/20230127014759/https://github.com/nodejs/node/commit/08b69fb1e8
Skip to content
Permalink
Browse files
lib: fix diagnostics_channel hasSubscribers error
Fixes: #36598

PR-URL: #36599
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
Lxxyx authored and targos committed May 1, 2021
1 parent 317a1d7 commit 08b69fb1e8667e4e04cb2dfed6ba3b60b8e4236e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
@@ -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'));

0 comments on commit 08b69fb

Please sign in to comment.
X Tutup