xref: /third_party/node/test/parallel/test-http-server-connections-checking-leak.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
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_cirequire('../common');
81cb0ef41Sopenharmony_ciconst onGC = require('../common/ongc');
91cb0ef41Sopenharmony_ciconst Countdown = require('../common/countdown');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst http = require('http');
121cb0ef41Sopenharmony_ciconst max = 100;
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci// Note that Countdown internally calls common.mustCall, that's why it's not done here.
151cb0ef41Sopenharmony_ciconst countdown = new Countdown(max, () => {});
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cifor (let i = 0; i < max; i++) {
181cb0ef41Sopenharmony_ci  const server = http.createServer((req, res) => {});
191cb0ef41Sopenharmony_ci  onGC(server, { ongc: countdown.dec.bind(countdown) });
201cb0ef41Sopenharmony_ci}
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_cisetImmediate(() => {
231cb0ef41Sopenharmony_ci  global.gc();
241cb0ef41Sopenharmony_ci});
25

Indexes created Thu Nov 07 10:32:03 CST 2024