Skip to content

Commit bb6d6a6

Browse files
santigimenoevanlucas
authored andcommitted
test: fix flaky test-child-process-pass-fd
Listen on random ports instead of using `common.PORT`. Fixes: #8209 PR-URL: #8212 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com>
1 parent e371545 commit bb6d6a6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/sequential/test-child-process-pass-fd.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const N = 80;
1414

1515
if (process.argv[2] !== 'child') {
1616
for (let i = 0; i < N; ++i) {
17-
const worker = fork(__filename, ['child', common.PORT + i]);
17+
const worker = fork(__filename, ['child']);
1818
worker.once('message', common.mustCall((msg, handle) => {
1919
assert.strictEqual(msg, 'handle');
2020
assert.ok(handle);
@@ -33,7 +33,6 @@ if (process.argv[2] !== 'child') {
3333
}
3434
} else {
3535
let socket;
36-
const port = process.argv[3];
3736
let cbcalls = 0;
3837
function socketConnected() {
3938
if (++cbcalls === 2)
@@ -47,7 +46,8 @@ if (process.argv[2] !== 'child') {
4746
});
4847
socketConnected();
4948
});
50-
server.listen(port, common.localhostIPv4, () => {
49+
server.listen(0, common.localhostIPv4, () => {
50+
const port = server.address().port;
5151
socket = net.connect(port, common.localhostIPv4, socketConnected);
5252
});
5353
}

0 commit comments

Comments
 (0)