diff --git a/test/parallel/test-cluster-worker-events.js b/test/parallel/test-cluster-worker-events.js index 91e716285dc2b8..3b156addedc63f 100644 --- a/test/parallel/test-cluster-worker-events.js +++ b/test/parallel/test-cluster-worker-events.js @@ -30,7 +30,7 @@ if (cluster.isMaster) { const worker = cluster.fork(); - worker.on('exit', function(code) { + worker.on('exit', (code) => { assert.strictEqual(code, OK); process.exit(0); }); @@ -49,31 +49,31 @@ assert(cluster.isWorker); let sawProcess; let sawWorker; -process.on('message', function(m) { - assert(!sawProcess); - sawProcess = true; - check(m); -}); - -cluster.worker.on('message', function(m) { - assert(!sawWorker); - sawWorker = true; - check(m); -}); - const messages = []; -function check(m) { +const check = (m) => { messages.push(m); if (messages.length < 2) return; assert.deepStrictEqual(messages[0], messages[1]); - cluster.worker.once('error', function(e) { + cluster.worker.once('error', (e) => { assert.strictEqual(e, 'HI'); process.exit(OK); }); process.emit('error', 'HI'); -} +}; + +process.on('message', (m) => { + assert(!sawProcess); + sawProcess = true; + check(m); +}); + +cluster.worker.on('message', (m) => { + assert(!sawWorker); + sawWorker = true; + check(m); +});