Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions test/parallel/test-cluster-eaddrinuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ const fork = require('child_process').fork;
const net = require('net');

const id = '' + process.argv[2];
const port = '' + process.argv[3];

if (id === 'undefined') {
const server = net.createServer(common.mustNotCall());
server.listen(common.PORT, function() {
const worker = fork(__filename, ['worker']);
server.listen(0, function() {
const worker = fork(__filename, ['worker', server.address().port]);
worker.on('message', function(msg) {
if (msg !== 'stop-listening') return;
server.close(function() {
Expand All @@ -44,14 +45,14 @@ if (id === 'undefined') {
});
} else if (id === 'worker') {
let server = net.createServer(common.mustNotCall());
server.listen(common.PORT, common.mustNotCall());
server.listen(port, common.mustNotCall());
server.on('error', common.mustCall(function(e) {
assert(e.code, 'EADDRINUSE');
process.send('stop-listening');
process.once('message', function(msg) {
if (msg !== 'stopped-listening') return;
server = net.createServer(common.mustNotCall());
server.listen(common.PORT, common.mustCall(function() {
server.listen(port, common.mustCall(function() {
server.close();
}));
});
Expand Down