Skip to content

Commit

Permalink
cluster: replace forEach with for-of loop
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
PR-URL: #50317
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
jerome-benoit authored and targos committed May 12, 2024
1 parent c676e52 commit 11e9789
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/internal/cluster/child.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@ function _disconnect(primaryInitiated) {
}
}

handles.forEach((handle) => {
for (const handle of handles.values()) {
waitingCount++;

if (handle[owner_symbol])
handle[owner_symbol].close(checkWaitingCount);
else
handle.close(checkWaitingCount);
});
}

handles.clear();
checkWaitingCount();
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/cluster/primary.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ function removeWorker(worker) {
function removeHandlesForWorker(worker) {
assert(worker);

handles.forEach((handle, key) => {
for (const { 0: key, 1: handle } of handles) {
if (handle.remove(worker))
handles.delete(key);
});
}
}

cluster.fork = function(env) {
Expand Down

0 comments on commit 11e9789

Please sign in to comment.