Skip to content

Commit 12287f1

Browse files
Sebastian PlesciucMylesBorins
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 53d5aac commit 12287f1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎test/parallel/test-cluster-eaddrinuse.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ const fork = require('child_process').fork;
99
constnet=require('net');
1010

1111
constid=''+process.argv[2];
12+
constport=''+process.argv[3];
1213

1314
if(id==='undefined'){
1415
constserver=net.createServer(common.mustNotCall());
15-
server.listen(common.PORT,function(){
16-
constworker=fork(__filename,['worker']);
16+
server.listen(0,function(){
17+
constworker=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
}elseif(id==='worker'){
2526
letserver=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)