Skip to content

Commit 5836b9f

Browse files
cjihrigtargos
authored andcommitted
doc: specify cluster worker.kill() caveat
worker.kill() relies on a graceful disconnect, which might not always be possible. This commit calls this out in the docs, and specifies worker.process.kill() as a non-graceful alternative. PR-URL: #23165 Fixes: #22703 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 8f5fb6f commit 5836b9f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/api/cluster.md

+5
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ This function will kill the worker. In the master, it does this by disconnecting
394394
the `worker.process`, and once disconnected, killing with `signal`. In the
395395
worker, it does it by disconnecting the channel, and then exiting with code `0`.
396396

397+
Because `kill()` attempts to gracefully disconnect the worker process, it is
398+
susceptible to waiting indefinitely for the disconnect to complete. For example,
399+
if the worker enters an infinite loop, a graceful disconnect will never occur.
400+
If the graceful disconnect behavior is not needed, use `worker.process.kill()`.
401+
397402
Causes `.exitedAfterDisconnect` to be set.
398403

399404
This method is aliased as `worker.destroy()` for backwards compatibility.

0 commit comments

Comments
 (0)