node/test/parallel/test-https-server-connections-checking-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

30 lines
684 B
JavaScript

'use strict';
// Flags: --expose-gc
// Check that creating a server without listening does not leak resources.
const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
}
const { onGC } = require('../common/gc');
const Countdown = require('../common/countdown');
const https = require('https');
const max = 100;
// Note that Countdown internally calls common.mustCall, that's why it's not done here.
const countdown = new Countdown(max, () => {});
for (let i = 0; i < max; i++) {
const server = https.createServer((req, res) => {});
onGC(server, { ongc: countdown.dec.bind(countdown) });
}
setImmediate(() => {
globalThis.gc();
});