Skip to main content
Cluster.workers - node__cluster.d.ts - Node documentation
property Cluster.workers

Usage in Deno

```typescript import { type Cluster } from "node:node__cluster.d.ts"; ```
A hash that stores the active worker objects, keyed by `id` field. This makes it easy to loop through all the workers. It is only available in the primary process. A worker is removed from `cluster.workers` after the worker has disconnected _and_ exited. The order between these two events cannot be determined in advance. However, it is guaranteed that the removal from the `cluster.workers` list happens before the last `'disconnect'` or `'exit'` event is emitted. ```js import cluster from 'node:cluster'; for (const worker of Object.values(cluster.workers)) { worker.send('big announcement to all workers'); } ```

Type

Dict<Worker> | undefined