Cluster

clusterWorker.isConnected()

Reports whether the IPC channel is connected. A connected worker is not necessarily ready to serve requests. Tested on Node.js 22.16.0. Example output (one line per entry): ["true", "false"].

Formal Syntax & Structure

nodejs syntaxnodejs
worker.isConnected()

Return Value

boolean

IPC connected state.

Working Example

Example Snippetnodejs
import cluster from 'node:cluster';import { once } from 'node:events';if (cluster.isPrimary) {    const w = cluster.fork({});    const done = once(w, 'exit');    await once(w, 'message');    console.log(w.isConnected());    const disconnected = once(w, 'disconnect');    w.disconnect();    await disconnected;    console.log(w.isConnected());    await done;}else {    process.send('ready');}
Node.js Reference