diff --git a/test/parallel/test-cluster-ipc-throw.js b/test/parallel/test-cluster-ipc-throw.js index f2e7f2822c7315..95c5d84ea6dbb0 100644 --- a/test/parallel/test-cluster-ipc-throw.js +++ b/test/parallel/test-cluster-ipc-throw.js @@ -2,20 +2,23 @@ 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.isMaster) { - server.listen(common.PORT); - const worker = cluster.fork(); - worker.on('exit', common.mustCall(() => { - server.close(); + 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((e) => {})); - server.listen(common.PORT); + server.listen(process.env.PORT); server.on('error', common.mustCall((e) => { cluster.worker.disconnect(); throw e;