Closed
Description
From the documentation:
Set by calling .kill() or .disconnect(), until then it is undefined.
In a worker, this function will close all servers, wait for the 'close' event on those servers, and then disconnect the IPC channel.
Causes .suicide to be set.
Repro:
var cluster = require('cluster');
if (cluster.isMaster) {
// Master forks and listens for events
var worker = cluster.fork();
cluster.on('disconnect', function(){
console.log("disconnect", worker.suicide);
});
cluster.on('exit', function(){
console.log("exit", worker.suicide);
});
} else {
// Worker just disconnects
cluster.worker.disconnect();
}
In node v0.10, both log statements would print true
for worker.suicide
. In 41b75ca, which landed during the v0.11 branch, this was broken, and all versions up to node v4 will print false
. This is because worker.disconnect()
, when called from the worker, does not send the suicide
message anymore -- only worker.destroy()
will send that message to the master.