11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// Test should fail in Node.js 5.4.1 and pass in later versions. 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ciconst cluster = require('cluster'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciif (cluster.isPrimary) { 111cb0ef41Sopenharmony_ci cluster.on('exit', (worker, code) => { 121cb0ef41Sopenharmony_ci assert.strictEqual(code, 0, `worker exited with code: ${code}, expected 0`); 131cb0ef41Sopenharmony_ci }); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci return cluster.fork(); 161cb0ef41Sopenharmony_ci} 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_cilet eventFired = false; 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_cicluster.worker.disconnect(); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciprocess.nextTick(common.mustCall(() => { 231cb0ef41Sopenharmony_ci assert.ok(!eventFired, 'disconnect event should wait for ack'); 241cb0ef41Sopenharmony_ci})); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_cicluster.worker.on('disconnect', common.mustCall(() => { 271cb0ef41Sopenharmony_ci eventFired = true; 281cb0ef41Sopenharmony_ci})); 29