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 <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
gengjiawen authored and BridgeAR committed Mar 12, 2019
1 parent 8b0164a commit 2a3cca7
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 @@ -80,10 +80,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 @@ -227,11 +224,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 2a3cca7

Please sign in to comment.