Skip to content

Commit

Permalink
cluster: improve for-loop
Browse files Browse the repository at this point in the history
PR-URL: #26336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
gengjiawen authored and BethGriggs committed Apr 16, 2019
1 parent e1f293c commit fb73c06
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/internal/cluster/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ cluster.setupMaster = function(options) {
if (message.cmd !== 'NODE_DEBUG_ENABLED')
return;

var key;
for (key in cluster.workers) {
const worker = cluster.workers[key];

for (const worker of Object.values(cluster.workers)) {
if (worker.state === 'online' || worker.state === 'listening') {
process._debugProcess(worker.process.pid);
} else {
Expand Down Expand Up @@ -231,11 +228,10 @@ cluster.disconnect = function(cb) {
if (workers.length === 0) {
process.nextTick(() => intercom.emit('disconnect'));
} else {
for (var key in workers) {
key = workers[key];

if (cluster.workers[key].isConnected())
cluster.workers[key].disconnect();
for (const worker of Object.values(cluster.workers)) {
if (worker.isConnected()) {
worker.disconnect();
}
}
}

Expand Down

0 comments on commit fb73c06

Please sign in to comment.