From e23ed07acc1d11ade304d89e3b04ac7740b38338 Mon Sep 17 00:00:00 2001 From: Paolo Insogna Date: Sat, 7 Nov 2026 10:41:14 +0100 Subject: [PATCH 1/3] worker: add diagnostic channel 'worker_threads.main.registry' Signed-off-by: Paolo Insogna Assisted-By: OpenAI:GPT-6.1 Sol --- doc/api/diagnostics_channel.md | 13 +++ lib/internal/worker/messaging.js | 11 +++ ...nostics-channel-worker-threads-registry.js | 81 +++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 test/parallel/test-diagnostics-channel-worker-threads-registry.js diff --git a/doc/api/diagnostics_channel.md b/doc/api/diagnostics_channel.md index 25e544ccf27b..0ef42dc1be54 100644 --- a/doc/api/diagnostics_channel.md +++ b/doc/api/diagnostics_channel.md @@ -2002,6 +2002,19 @@ added: v16.18.0 Emitted when a new thread is created. +##### Event: `'worker_threads.main.registry'` + +* `threadIds` {number[]} A snapshot of the registered worker thread IDs. + +Emitted only on the main thread whenever a worker's messaging port is registered +or unregistered, including workers created by other workers. The main thread's +ID (`0`) is not included. + +Registration can occur before a worker is online. Unregistration occurs when the +parent thread processes the worker's exit, so it can be delayed if the parent +thread is blocked. The snapshot represents registered messaging ports, not a +guarantee that the listed workers are ready or still running. + #### SQLite