From 063c9f68865e1c5049fd4f29a547cad1b6fa7642 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 1 Jan 2016 13:26:23 -0800 Subject: test: fix flaky test-cluster-shared-leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wait for worker2 to come online before doing anything that might result in an EPIPE. Fixes flakiness of test on Windows. Fixes: https://github.com/nodejs/node/issues/3956 PR-URL: https://github.com/nodejs/node/pull/4510 Reviewed-By: Johan Bergström Reviewed-By: James M Snell --- test/parallel/test-cluster-shared-leak.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'test/parallel/test-cluster-shared-leak.js') diff --git a/test/parallel/test-cluster-shared-leak.js b/test/parallel/test-cluster-shared-leak.js index a4de1d33a2..55df57c983 100644 --- a/test/parallel/test-cluster-shared-leak.js +++ b/test/parallel/test-cluster-shared-leak.js @@ -15,14 +15,16 @@ 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') - throw e; + worker2.on('online', 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') + throw e; + }); }); })); -- cgit v1.2.3