Skip to content

worker: add diagnostic channel 'worker_threads.main.registry' - #67311

Merged
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
ShogunPanda:threads-registry
Nov 20, 2026
Merged

nodejs-github-bot merged 5 commits into
nodejs:mainfrom
ShogunPanda:threads-registry

Conversation

@ShogunPanda

Copy link
Copy Markdown
Contributor

Summary

Add worker_threads.main.registry to expose changes to the worker messaging registry through diagnostics_channel.

Changes

  • Publish { threadIds } snapshots on registration and removal, including nested workers.
  • Emit exclusively on the main thread and allocate snapshots only when subscribers exist.
  • Document lifecycle limitations and cover registry updates, snapshot independence, and main-thread-only publication.

Notes

Registration does not guarantee readiness. Removal depends on the parent processing the worker's exit and can be delayed if the parent is blocked.

Additional Informations

AI-assisted work. All changes reviewed by a human.

Signed-off-by: Paolo Insogna <paolo@cowtech.it>
Assisted-By: OpenAI:GPT-6.1 Sol <openai/gpt-6.1-sol>
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. worker Issues and PRs related to the worker_threads module and Worker API. labels Nov 7, 2026
@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.67%. Comparing base (a43bfb5) to head (3152ebb).
⚠️ Report is 233 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67311      +/-   ##
==========================================
- Coverage   93.00%   90.67%   -2.33%     
==========================================
  Files         428      800     +372     
  Lines      195818   281098   +85280     
  Branches    30283    54317   +24034     
==========================================
+ Hits       182117   254881   +72764     
- Misses      13375    16303    +2928     
- Partials      326     9914    +9588     
Files with missing lines Coverage Δ
lib/internal/worker/messaging.js 100.00% <100.00%> (+1.65%) ⬆️

... and 557 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Paolo Insogna <paolo@cowtech.it>
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 9, 2026

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 16, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread lib/internal/worker/messaging.js Outdated
port.unref();

if (registryChannel.hasSubscribers) {
registryChannel.publish({ threadIds: ArrayFrom(threadsPorts.keys()) });

@jasnell jasnell Nov 16, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I haven't checked the convention for other things, but I suspect we should be using null proto objects for these. (not blocking)

Comment thread doc/api/diagnostics_channel.md Resolved
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
Assisted-by: GPT-6.1 Sol
@ShogunPanda

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @jasnell! Both registry event payloads now use null-prototype objects, and the test checks this explicitly.

I also updated the documentation to describe the worker thread registry first, then explain how internal messaging ports track its entries and why snapshots do not guarantee that workers are ready or still running. I kept the channel name unchanged.

Could you take another look?

@ShogunPanda
ShogunPanda requested a review from jasnell November 16, 2026 16:24
@mcollina

Copy link
Copy Markdown
Member

CI is red

Identify workers created by the test explicitly and skip execution
when started inside the CI worker wrapper.

Assisted-by: GPT-6.1 Sol
Signed-off-by: Paolo Insogna <paolo@cowtech.it>

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm.

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 17, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 17, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 17, 2026
@github-actions github-actions Bot added request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. and removed request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Failed to start CI

   ℹ  Existing CI run found: https://ci.nodejs.org/job/node-test-pull-request/79217/
   ✖  Refusing to start a potentially duplicate CI job. The existing CI run is still in progress.
Full Auto Start CI output
�[36m⠋�[39m Getting reviews from nodejs/node/pull/67311
�[36m⠋�[39m Getting commits from nodejs/node/pull/67311
�[36m⠙�[39m Validating Jenkins credentials
�[36m⠙�[39m Validating Jenkins credentials
✔  Jenkins credentials valid
�[36m⠹�[39m Getting comments from nodejs/node/pull/67311
�[36m⠸�[39m Querying data for job/node-test-pull-request/79217/
�[36m⠸�[39m Querying data for job/node-test-pull-request/79217/
�[36m⠸�[39m Querying API for job/node-test-pull-request/79217/
✔  Build data downloaded
   ℹ  Existing CI run found: https://ci.nodejs.org/job/node-test-pull-request/79217/
   ✖  Refusing to start a potentially duplicate CI job. The existing CI run is still in progress.

View workflow run

@ShogunPanda ShogunPanda removed the request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. label Nov 17, 2026
@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 18, 2026
@github-actions github-actions Bot added request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. and removed request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Nov 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Failed to start CI

   ℹ  Existing CI run found: https://ci.nodejs.org/job/node-test-pull-request/79217/
   ✖  Refusing to start a potentially duplicate CI job. Resume CI by adding the "resume-ci" label to the PR, or run: ncu-ci resume https://github.com/nodejs/node/pull/67311
Full Auto Start CI output
�[36m⠋�[39m Getting reviews from nodejs/node/pull/67311
�[36m⠋�[39m Getting commits from nodejs/node/pull/67311
�[36m⠙�[39m Validating Jenkins credentials
�[36m⠙�[39m Validating Jenkins credentials
✔  Jenkins credentials valid
�[36m⠹�[39m Getting comments from nodejs/node/pull/67311
�[36m⠸�[39m Querying data for job/node-test-pull-request/79217/
�[36m⠸�[39m Querying data for job/node-test-pull-request/79217/
�[36m⠸�[39m Querying API for job/node-test-pull-request/79217/
✔  Build data downloaded
   ℹ  Existing CI run found: https://ci.nodejs.org/job/node-test-pull-request/79217/
   ✖  Refusing to start a potentially duplicate CI job. Resume CI by adding the "resume-ci" label to the PR, or run: ncu-ci resume https://github.com/nodejs/node/pull/67311

View workflow run

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda added commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-squash PRs the Commit Queue should land as one squashed commit. and removed request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. labels Nov 19, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 50ba1ec into nodejs:main Nov 20, 2026
76 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 50ba1ec

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 20, 2026
aduh95 pushed a commit that referenced this pull request Nov 20, 2026
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
Assisted-By: OpenAI:GPT-6.1 Sol <openai/gpt-6.1-sol>
PR-URL: #67311
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-squash PRs the Commit Queue should land as one squashed commit. needs-ci PRs that need a full CI run. worker Issues and PRs related to the worker_threads module and Worker API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants