node/test/parallel/test-primitive-timer-leak.js
James M Snell 97a3a8204c test: replace more uses of global with globalThis
PR-URL: https://github.com/nodejs/node/pull/56712
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2025-01-25 07:23:11 +00:00

24 lines
442 B
JavaScript

'use strict';
// Flags: --expose-gc
require('../common');
const { onGC } = require('../common/gc');
// See https://github.com/nodejs/node/issues/53335
const poller = setInterval(() => {
globalThis.gc();
}, 100);
let count = 0;
for (let i = 0; i < 10; i++) {
const timer = setTimeout(() => {}, 0);
onGC(timer, {
ongc: () => {
if (++count === 10) {
clearInterval(poller);
}
}
});
console.log(+timer);
}