0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-cluster-rr-handle-ref-unref.js
theanarkh 78954846c3
src,lib: the handle keeps loop alive in cluster rr mode
PR-URL: https://github.com/nodejs/node/pull/46161
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2023-01-16 13:57:39 +00:00

21 lines
464 B
JavaScript

'use strict';
const common = require('../common');
const cluster = require('cluster');
const net = require('net');
cluster.schedulingPolicy = cluster.SCHED_RR;
if (cluster.isPrimary) {
const worker = cluster.fork();
worker.on('exit', common.mustCall());
} else {
const server = net.createServer(common.mustNotCall());
server.listen(0, common.mustCall(() => {
server.ref();
server.unref();
process.channel.unref();
}));
server.unref();
}