xref: /third_party/node/test/parallel/test-cluster-disconnect-leak.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Test fails in Node v5.4.0 and passes in v5.4.1 and newer.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst common = require('../common');
61cb0ef41Sopenharmony_ciconst net = require('net');
71cb0ef41Sopenharmony_ciconst cluster = require('cluster');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_cicluster.schedulingPolicy = cluster.SCHED_NONE;
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciif (cluster.isPrimary) {
121cb0ef41Sopenharmony_ci  const worker = cluster.fork();
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci  // This is the important part of the test: Confirm that `disconnect` fires.
151cb0ef41Sopenharmony_ci  worker.on('disconnect', common.mustCall());
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  // These are just some extra stuff we're checking for good measure...
181cb0ef41Sopenharmony_ci  worker.on('exit', common.mustCall());
191cb0ef41Sopenharmony_ci  cluster.on('exit', common.mustCall());
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci  cluster.disconnect();
221cb0ef41Sopenharmony_ci  return;
231cb0ef41Sopenharmony_ci}
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciconst server = net.createServer();
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ciserver.listen(0);
28

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