Skip to content

Commit aadfe6c

Browse files
committed
cluster: close ownerless handles on disconnect()
When a worker is disconnecting, it shuts down all of the handles it is waiting on. It is possible that a handle does not have an owner, which causes a crash. This commit closes such handles without accessing the missing owner. Fixes: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
1 parent dd21bd9 commit aadfe6c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/cluster.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,11 @@ function workerInit() {
719719
const handle = handles[key];
720720
delete handles[key];
721721
waitingCount++;
722-
handle.owner.close(checkWaitingCount);
722+
723+
if (handle.owner)
724+
handle.owner.close(checkWaitingCount);
725+
else
726+
handle.close(checkWaitingCount);
723727
}
724728

725729
checkWaitingCount();

0 commit comments

Comments
 (0)