diff --git a/test/parallel/test-cluster-bind-twice.js b/test/parallel/test-cluster-bind-twice.js index 215d4829ce215e..af3e89e05ce056 100644 --- a/test/parallel/test-cluster-bind-twice.js +++ b/test/parallel/test-cluster-bind-twice.js @@ -46,9 +46,8 @@ if (!id) { a.on('message', common.mustCall((m) => { - if (typeof m === 'object') return; - assert.strictEqual(m, 'READY'); - b.send('START'); + assert.strictEqual(m.msg, 'READY'); + b.send({msg: 'START', port: m.port}); })); b.on('message', common.mustCall((m) => { @@ -60,10 +59,10 @@ if (!id) { } else if (id === 'one') { if (cluster.isMaster) return startWorker(); - http.createServer(common.mustNotCall()) - .listen(common.PORT, common.mustCall(() => { - process.send('READY'); - })); + const server = http.createServer(common.mustNotCall()); + server.listen(0, common.mustCall(() => { + process.send({msg: 'READY', port: server.address().port}); + })); process.on('message', common.mustCall((m) => { if (m === 'QUIT') process.exit(); @@ -74,8 +73,8 @@ if (!id) { const server = http.createServer(common.mustNotCall()); process.on('message', common.mustCall((m) => { if (m === 'QUIT') process.exit(); - assert.strictEqual(m, 'START'); - server.listen(common.PORT, common.mustNotCall()); + assert.strictEqual(m.msg, 'START'); + server.listen(m.port, common.mustNotCall()); server.on('error', common.mustCall((e) => { assert.strictEqual(e.code, 'EADDRINUSE'); process.send(e.code);