Repository navigation
Conversation
node:worker_threads mixes the APIs of worker threads with ones that are about messaging between any threads, and with classes that are globals. Add node:threads/worker for the former and node:threads/messaging for markAsUntransferable(), markAsUncloneable(), isMarkedAsUntransferable(), moveMessagePortToContext() and receiveMessageOnPort(). MessageChannel, MessagePort, BroadcastChannel and navigator.locks are globals already, so neither module exports them. Both modules export the same objects as node:worker_threads, and can only be loaded with the node: scheme, as `threads` is taken on npm. node:worker_threads is unchanged, and documented as legacy. The documentation moves to threads.md. worker_threads.md maps each of its exports to its new location. Assisted-by: Claude Opus 5.5 Signed-off-by: James M Snell <jasnell@gmail.com>
|
Review requested:
|
In builds with pointer compression, every Worker is created in an isolate group of its own, so each has a 4 GB pointer compression cage and a read-only heap to itself. Add node:threads, with an IsolateGroup class: `new IsolateGroup()` creates a group, `IsolateGroup.current` is the group of the current thread, and `IsolateGroup.supported` tells whether the build can create groups. Passing one as the `isolateGroup` option of Worker creates the worker's isolate in that group, so that workers can share it with each other or with the thread that creates them. Workers created without the option are unchanged. Assisted-by: Claude Opus 5.5 Signed-off-by: James M Snell <jasnell@gmail.com>
b23f24d to
f88b09e
Compare
|
The
notable-change
Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67801 +/- ##
==========================================
+ Coverage 90.50% 90.52% +0.02%
==========================================
Files 805 809 +4
Lines 285818 286021 +203
Branches 55182 55204 +22
==========================================
+ Hits 258666 258914 +248
+ Misses 17251 17199 -52
- Partials 9901 9908 +7
🚀 New features to boost your workflow:
|
mcollina
left a comment
There was a problem hiding this comment.
Can you split IsolateGroups out in its own PR?
Also, this is not actually moving anything apart from docs. We would need to keep the old aliases for a long time. Anyway, we should include doc-deprecations for the old module.
This is a follow up to the discussion in #67288 on how to organize the worker threads and future green threads modules around a new
node:threads/*namespace.This one moves the exports from
node:workers_threadsto newnode:threads/node:threads/messaging/node:threads/workermodules.It also adds the
IsolateGroupsupport to worker threads./cc @jsumners-nr @ronag