diff --git a/test/simple/test-cluster-master-error.js b/test/simple/test-cluster-master-error.js index a9b9896179..5e0e3fac60 100644 --- a/test/simple/test-cluster-master-error.js +++ b/test/simple/test-cluster-master-error.js @@ -112,16 +112,21 @@ if (cluster.isWorker) { // Check that the cluster died accidently existMaster = (code === 1); - // When master is dead all workers should be dead to - var alive = false; - workers.forEach(function(pid) { - if (isAlive(pid)) { - alive = true; - } - }); + // Give the workers time to shut down + setTimeout(checkWorkers, 200); + + function checkWorkers() { + // When master is dead all workers should be dead to + var alive = false; + workers.forEach(function(pid) { + if (isAlive(pid)) { + alive = true; + } + }); - // If a worker was alive this did not act as expected - existWorker = !alive; + // If a worker was alive this did not act as expected + existWorker = !alive; + } }); process.once('exit', function() {