node/test/parallel/test-diagnostics-channel-gc-maintains-subcriptions.js
Ugaitz Urien 897932c484
diagnostics_channel: fix race condition with diagnostics_channel and GC
PR-URL: https://github.com/nodejs/node/pull/59910
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2025-09-19 07:28:39 +00:00

22 lines
402 B
JavaScript

// Flags: --expose-gc
'use strict';
require('../common');
const assert = require('assert');
const { channel } = require('diagnostics_channel');
function test() {
function subscribe() {
channel('test-gc').subscribe(function noop() {});
}
subscribe();
setTimeout(() => {
global.gc();
assert.ok(channel('test-gc').hasSubscribers, 'Channel must have subscribers');
});
}
test();