0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-cluster-ipc-throw.js
Antoine du Hamel 2c1b9f506a
test: remove unnecessary noop function args to mustCall()
RefsL https://github.com/nodejs/node/pull/45027

PR-URL: https://github.com/nodejs/node/pull/45047
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
2022-10-20 13:13:32 +00:00

27 lines
690 B
JavaScript

'use strict';
const common = require('../common');
const http = require('http');
const cluster = require('cluster');
const assert = require('assert');
cluster.schedulingPolicy = cluster.SCHED_RR;
const server = http.createServer();
if (cluster.isPrimary) {
server.listen({ port: 0 }, common.mustCall(() => {
const worker = cluster.fork({ PORT: server.address().port });
worker.on('exit', common.mustCall(() => {
server.close();
}));
}));
} else {
assert(process.env.PORT);
process.on('uncaughtException', common.mustCall());
server.listen(process.env.PORT);
server.on('error', common.mustCall((e) => {
cluster.worker.disconnect();
throw e;
}));
}