Skip to content

Commit b82e076

Browse files
Sebastian Plesciucevanlucas
Sebastian Plesciuc
authored andcommitted
test: dynamic port in cluster eaddrinuse
Removed common.PORT from test-cluster-eaddrinuse to eliminate the possibility that a dynamic port used in another test will collide with common.PORT. PR-URL: #12547 Ref: #12376 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 8ae5afe commit b82e076

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/parallel/test-cluster-eaddrinuse.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ const fork = require('child_process').fork;
99
const net = require('net');
1010

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

1314
if (id === 'undefined') {
1415
const server = net.createServer(common.mustNotCall());
15-
server.listen(common.PORT, function() {
16-
const worker = fork(__filename, ['worker']);
16+
server.listen(0, function() {
17+
const worker = fork(__filename, ['worker', server.address().port]);
1718
worker.on('message', function(msg) {
1819
if (msg !== 'stop-listening') return;
1920
server.close(function() {
@@ -23,14 +24,14 @@ if (id === 'undefined') {
2324
});
2425
} else if (id === 'worker') {
2526
let server = net.createServer(common.mustNotCall());
26-
server.listen(common.PORT, common.mustNotCall());
27+
server.listen(port, common.mustNotCall());
2728
server.on('error', common.mustCall(function(e) {
2829
assert(e.code, 'EADDRINUSE');
2930
process.send('stop-listening');
3031
process.once('message', function(msg) {
3132
if (msg !== 'stopped-listening') return;
3233
server = net.createServer(common.mustNotCall());
33-
server.listen(common.PORT, common.mustCall(function() {
34+
server.listen(port, common.mustCall(function() {
3435
server.close();
3536
}));
3637
});

0 commit comments

Comments
 (0)