Skip to content

Commit f152adf

Browse files
cjihrigMyles Borins
authored and
Myles Borins
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 c0a42bc commit f152adf

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
@@ -703,7 +703,11 @@ function workerInit() {
703703
const handle = handles[key];
704704
delete handles[key];
705705
waitingCount++;
706-
handle.owner.close(checkWaitingCount);
706+
707+
if (handle.owner)
708+
handle.owner.close(checkWaitingCount);
709+
else
710+
handle.close(checkWaitingCount);
707711
}
708712

709713
checkWaitingCount();

0 commit comments

Comments
 (0)