Skip to content

Commit 8e7df04

Browse files
tniessenruyadorno
authored andcommittedFeb 7, 2022
doc: remove unadvisable cluster example
Applications should usually keep track of workers themselves to prevent cross-referencing workers from different "groups" that are assigned to separate tasks. Additionally, it is unreasonable to assume that the 'data' event emitted by a socket object will be an integer. While the example works when the argument is a string (or Buffer), it can result in various issues (e.g., when id === '__proto__' since cluster.workers has a non-null prototype). Refs: 5f08c3c PR-URL: #41668 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Mestery <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tierney Cyren <[email protected]>
1 parent 0ee468d commit 8e7df04

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed
 

‎doc/api/cluster.md

-8
Original file line numberDiff line numberDiff line change
@@ -1087,14 +1087,6 @@ for (const worker of Object.values(cluster.workers)) {
10871087
}
10881088
```
10891089

1090-
Using the worker's unique id is the easiest way to locate the worker.
1091-
1092-
```js
1093-
socket.on('data', (id) => {
1094-
const worker = cluster.workers[id];
1095-
});
1096-
```
1097-
10981090
[Advanced serialization for `child_process`]: child_process.md#advanced-serialization
10991091
[Child Process module]: child_process.md#child_processforkmodulepath-args-options
11001092
[`.fork()`]: #clusterforkenv

0 commit comments

Comments
 (0)