You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
var cluster = require('cluster');
var net = require('net');
if (cluster.isMaster) {
var worker = cluster.fork().on('online', function workerOnline() {
worker.disconnect();
});
} else {
net.createServer(function(client) {}).listen(8000);
}
assert.js:98
throw new assert.AssertionError({
^
AssertionError: Resource leak detected.
at removeWorker (cluster.js:346:9)
at ChildProcess.<anonymous> (cluster.js:366:34)
at ChildProcess.g (events.js:199:16)
at ChildProcess.emit (events.js:110:17)
at Process.ChildProcess._handle.onexit (child_process.js:1057:12)
Tested with node built from the tip of v0.12 on MacOS X.
My recommendation would be to change the Worker.prototype.isConnected method to an internal hasDisconnected method that returns true only after the disconnect event handler has run.
EDIT: We could maybe just add an internal hasDisconnected method instead of replacing the Worker.prototype.isConnected method.
The text was updated successfully, but these errors were encountered:
@sam-github Putting you in the loop, since you know the cluster module very well. This bug is due to one of my changes (90d1147), but if you have some time to fix it, please feel free to do it. Otherwise I'll get to that later.
@sam-github Also, I think that currently our tests for the cluster module always run with the default scheduling policy. I would like to add the ability to run all cluster tests once for each policy that we have (currently only two, shared and round-robin). If that makes sense, I suggest creating a separate issue for that. What do you think?
The following code:
When run like following:
asserts with the following error:
Tested with node built from the tip of v0.12 on MacOS X.
The problem is that the
exit
event's handler is called before thedisconnect
event handler, but theWorker.prototype.isConnected
method returns false sinceworker.process.connected
has already been set to false.So we haven't had the time to remove the handle before removing the worker, and thus we assert.
My recommendation would be to change the
Worker.prototype.isConnected
method to an internalhasDisconnected
method that returns true only after thedisconnect
event handler has run.EDIT: We could maybe just add an internal
hasDisconnected
method instead of replacing theWorker.prototype.isConnected
method.The text was updated successfully, but these errors were encountered: