diff --git a/lib/cluster.js b/lib/cluster.js index 651b2f481d..d60366aaf1 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -684,10 +684,12 @@ function workerInit() { Worker.prototype.destroy = function() { this.exitedAfterDisconnect = true; - if (!this.isConnected()) process.exit(0); - var exit = process.exit.bind(null, 0); - send({ act: 'exitedAfterDisconnect' }, () => process.disconnect()); - process.once('disconnect', exit); + if (!this.isConnected()) { + process.exit(0); + } else { + send({ act: 'exitedAfterDisconnect' }, () => process.disconnect()); + process.once('disconnect', () => process.exit(0)); + } }; function send(message, cb) {