Skip to content

Commit 4624147

Browse files
committed
test: fix EPIPE on Windows
test-cluster-shared-leak.js was flaky because a worker can emit EPIPE. Wait for workers to be listening so that EPIPE does not happen. Fixes: #3956 PR-URL: #4173
1 parent c0cb80e commit 4624147

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

test/parallel/parallel.status

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ prefix parallel
99
[$system==win32]
1010
test-child-process-fork-regr-gh-2847 : PASS,FLAKY
1111
test-cluster-net-send : PASS,FLAKY
12-
test-cluster-shared-leak : PASS,FLAKY
1312
test-tls-ticket-cluster : PASS,FLAKY
1413

1514
[$system==linux]

test/parallel/test-cluster-shared-leak.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ if (cluster.isMaster) {
1515
worker1 = cluster.fork();
1616
worker1.on('message', common.mustCall(function() {
1717
worker2 = cluster.fork();
18-
conn = net.connect(common.PORT, common.mustCall(function() {
19-
worker1.send('die');
20-
worker2.send('die');
21-
}));
22-
conn.on('error', function(e) {
23-
// ECONNRESET is OK
24-
if (e.code !== 'ECONNRESET')
18+
// make sure worker2 is listening before doing anything else
19+
cluster.once('listening', function() {
20+
conn = net.connect(common.PORT, common.mustCall(function() {
21+
worker1.send('die');
22+
worker2.send('die');
23+
}));
24+
conn.on('error', function(e) {
25+
// ECONNRESET is OK
26+
if (e.code === 'ECONNRESET')
27+
return;
2528
throw e;
29+
});
2630
});
2731
}));
2832

0 commit comments

Comments
 (0)