Skip to content

Commit 8ae5afe

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

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/parallel/test-cluster-ipc-throw.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22
const common = require('../common');
33
const http = require('http');
44
const cluster = require('cluster');
5+
const assert = require('assert');
56

67
cluster.schedulingPolicy = cluster.SCHED_RR;
78

89
const server = http.createServer();
910

1011
if (cluster.isMaster) {
11-
server.listen(common.PORT);
12-
const worker = cluster.fork();
13-
worker.on('exit', common.mustCall(() => {
14-
server.close();
12+
server.listen({port: 0}, common.mustCall(() => {
13+
const worker = cluster.fork({PORT: server.address().port});
14+
worker.on('exit', common.mustCall(() => {
15+
server.close();
16+
}));
1517
}));
1618
} else {
19+
assert(process.env.PORT);
1720
process.on('uncaughtException', common.mustCall((e) => {}));
18-
server.listen(common.PORT);
21+
server.listen(process.env.PORT);
1922
server.on('error', common.mustCall((e) => {
2023
cluster.worker.disconnect();
2124
throw e;

0 commit comments

Comments
 (0)