Skip to content

Commit

Permalink
test: fix EPIPE on Windows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Trott committed Dec 8, 2015
1 parent c0cb80e commit 4624147
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ prefix parallel
[$system==win32]
test-child-process-fork-regr-gh-2847 : PASS,FLAKY
test-cluster-net-send : PASS,FLAKY
test-cluster-shared-leak : PASS,FLAKY
test-tls-ticket-cluster : PASS,FLAKY

[$system==linux]
Expand Down
18 changes: 11 additions & 7 deletions test/parallel/test-cluster-shared-leak.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ if (cluster.isMaster) {
worker1 = cluster.fork();
worker1.on('message', common.mustCall(function() {
worker2 = cluster.fork();
conn = net.connect(common.PORT, common.mustCall(function() {
worker1.send('die');
worker2.send('die');
}));
conn.on('error', function(e) {
// ECONNRESET is OK
if (e.code !== 'ECONNRESET')
// make sure worker2 is listening before doing anything else
cluster.once('listening', function() {
conn = net.connect(common.PORT, common.mustCall(function() {
worker1.send('die');
worker2.send('die');
}));
conn.on('error', function(e) {
// ECONNRESET is OK
if (e.code === 'ECONNRESET')
return;
throw e;
});
});
}));

Expand Down

0 comments on commit 4624147

Please sign in to comment.