From 462414756ea21d83e5c83288d58301d44859f67f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 5 Dec 2015 19:37:23 -0800 Subject: [PATCH] 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: https://github.com/nodejs/node/issues/3956 PR-URL: https://github.com/nodejs/node/pull/4173 --- test/parallel/parallel.status | 1 - test/parallel/test-cluster-shared-leak.js | 18 +++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index b4d449a6f57ef0..0497224725e7e3 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -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] diff --git a/test/parallel/test-cluster-shared-leak.js b/test/parallel/test-cluster-shared-leak.js index a4de1d33a29b8d..8fe2f522abe25e 100644 --- a/test/parallel/test-cluster-shared-leak.js +++ b/test/parallel/test-cluster-shared-leak.js @@ -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; + }); }); }));