Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,13 @@ 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()) {
exit();
} else {
send({ act: 'exitedAfterDisconnect' }, () => process.disconnect());
process.once('disconnect', exit);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not eliminate the bind() altogether?

if (!this.isConnected()) {
  process.exit(0);
} else {
  send({ act: 'exitedAfterDisconnect' }, () => process.disconnect());
  process.once('disconnect', () => process.exit(0));
}

};

function send(message, cb) {
Expand Down