11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// Flags: --expose-gc 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// Check that creating a server without listening does not leak resources. 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst common = require('../common'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciif (!common.hasCrypto) { 101cb0ef41Sopenharmony_ci common.skip('missing crypto'); 111cb0ef41Sopenharmony_ci} 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciconst onGC = require('../common/ongc'); 141cb0ef41Sopenharmony_ciconst Countdown = require('../common/countdown'); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst https = require('https'); 171cb0ef41Sopenharmony_ciconst max = 100; 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci// Note that Countdown internally calls common.mustCall, that's why it's not done here. 201cb0ef41Sopenharmony_ciconst countdown = new Countdown(max, () => {}); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_cifor (let i = 0; i < max; i++) { 231cb0ef41Sopenharmony_ci const server = https.createServer((req, res) => {}); 241cb0ef41Sopenharmony_ci onGC(server, { ongc: countdown.dec.bind(countdown) }); 251cb0ef41Sopenharmony_ci} 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_cisetImmediate(() => { 281cb0ef41Sopenharmony_ci global.gc(); 291cb0ef41Sopenharmony_ci}); 30