diff --git a/test/parallel/test-child-process-fork-regr-gh-2847.js b/test/parallel/test-child-process-fork-regr-gh-2847.js index e7815db1b471c1..7b4c262fbdcf61 100644 --- a/test/parallel/test-child-process-fork-regr-gh-2847.js +++ b/test/parallel/test-child-process-fork-regr-gh-2847.js @@ -49,14 +49,19 @@ var server = net.createServer(function(s) { server.close(); })); - send(); - send(function(err) { - // Ignore errors when sending the second handle because the worker - // may already have exited. - if (err) { - if (err.code !== 'ECONNREFUSED') { - throw err; - } - } + worker.on('online', function() { + send(function(err) { + assert.ifError(err); + send(function(err) { + // Ignore errors when sending the second handle because the worker + // may already have exited. + if (err) { + if ((err.message !== 'channel closed') && + (err.code !== 'ECONNREFUSED')) { + throw err; + } + } + }); + }); }); });