Repository navigation
node:worker_threads: worker and messaging parity cut #2507
Description
Summary
Use this issue as the parent tracker for practical node:worker_threads compatibility work. Perry has some environment-data and synthetic parentPort support, plus main-thread shape rows for isMainThread, threadId, and resourceLimits, but the Node-compatible Worker, messaging, diagnostics, Web Locks, and advanced option surfaces still need focused implementation cuts.
Concrete PR Cuts
- node:worker_threads: message channels and clone markers parity cut #3307 - message channels and clone markers parity cut
- node:worker_threads: execute Worker files with parentPort messaging #3156 - Worker file execution and parentPort messaging
- node:worker_threads: expose Worker stdio streams and option state #3330 - Worker stdio streams and option state
- node:worker_threads: expose Worker diagnostics and profiling APIs #3329 - Worker diagnostics and profiling APIs
- node:worker_threads: implement Web Locks request and query #3328 - Web Locks request/query surface
Child Issues
- node:worker_threads: execute Worker files with parentPort messaging #3156 - execute Worker files with parentPort messaging
- node:worker_threads: implement MessageChannel ports and receiveMessageOnPort #3157 - implement MessageChannel ports and receiveMessageOnPort
- node:worker_threads: expose BroadcastChannel message delivery #3158 - expose BroadcastChannel message delivery
- node:worker_threads: implement transfer and clone marker helpers #3159 - implement transfer and clone marker helpers
- node:worker_threads: deliver direct thread messages with postMessageToThread #3326 - deliver direct thread messages with postMessageToThread
- node:worker_threads: move MessagePort objects into vm contexts #3327 - move MessagePort objects into vm contexts
- node:worker_threads: implement Web Locks request and query #3328 - implement Web Locks request and query
- node:worker_threads: expose Worker diagnostics and profiling APIs #3329 - expose Worker diagnostics and profiling APIs
- node:worker_threads: expose Worker stdio streams and option state #3330 - expose Worker stdio streams and option state
Intended PR Boundary
Implement worker_threads in coherent medium slices:
- node:worker_threads: message channels and clone markers parity cut #3307 for Node-compatible message transport primitives:
MessageChannel,MessagePort,receiveMessageOnPort,BroadcastChannel,moveMessagePortToContext, and structured-clone marker state; - node:worker_threads: execute Worker files with parentPort messaging #3156 plus node:worker_threads: deliver direct thread messages with postMessageToThread #3326/node:worker_threads: expose Worker stdio streams and option state #3330 for Worker execution: spawning JS worker files, parent/worker
postMessage,postMessageToThread,workerData, lifecycle events,terminate, refs,threadId,threadName,resourceLimits, stdio streams, and option state; - node:worker_threads: expose Worker diagnostics and profiling APIs #3329 for Worker diagnostics/profiling once Worker handles exist;
- node:worker_threads: implement Web Locks request and query #3328 for the experimental Web Locks surface as a separate local lock-manager cut;
- focused parity coverage beyond the current generated shape probe.
This keeps worker_threads as medium PRs while avoiding broad scheduler/runtime rewrites.
Node Behavior
Node's worker_threads module can spawn JavaScript workers, expose per-thread module state, exchange structured-clone messages through parentPort, route direct postMessageToThread messages, create in-process message channels, synchronously receive queued port messages, broadcast across same-name channels, mark values as non-transferable or non-cloneable, expose Worker stdio/diagnostic APIs, and manage experimental Web Locks.
Perry Behavior
docs/runtime-parity-gaps.md lists about 60 remaining node:worker_threads gaps. test-files/test_parity_worker_threads.ts mostly type-probes the missing surfaces, while test-parity/node-suite/worker_threads/environment-data/basic.ts now covers the implemented environment-data slice. crates/perry-stdlib/src/worker_threads.rs implements environment data, workerData from PERRY_WORKER_DATA, a synthetic parentPort, JSON-over-stdin/stdout parentPort.postMessage, and parentPort.on('message'|'close'). crates/perry-api-manifest/src/entries.rs exposes the implemented environment-data and main-thread shape rows plus generic postMessage wiring, but source search found no Node-compatible Worker constructor, MessageChannel/BroadcastChannel transport, direct thread messaging, Web Locks, diagnostics, or stdio option implementation.
Non-goals
- Replacing Perry's
perry/threadAPIs or changing their public semantics. - Broad scheduler/runtime rewrites unrelated to Node-observable worker_threads behavior.
- Treating Worker diagnostics, Web Locks, or stdio option support as required for the first Worker execution PR; those have separate child issues above.
Acceptance
- Concrete cut node:worker_threads: message channels and clone markers parity cut #3307 and child issue node:worker_threads: execute Worker files with parentPort messaging #3156 have focused parity/regression coverage as they land.
- New follow-up children node:worker_threads: deliver direct thread messages with postMessageToThread #3326, node:worker_threads: move MessagePort objects into vm contexts #3327, node:worker_threads: implement Web Locks request and query #3328, node:worker_threads: expose Worker diagnostics and profiling APIs #3329, and node:worker_threads: expose Worker stdio streams and option state #3330 stay explicit instead of being hidden under broad non-goals.
- Existing generated
test_parity_worker_threadsadvances beyond type/shape probes for the covered APIs. - Docs/gap metadata stop presenting covered rows as missing.
- Deferred Web Locks, worker diagnostics, direct messaging, and advanced Worker stream/resource-limit options remain tracked separately until implemented.
Activity
[-]node:worker_threads: implement Worker and message channel surfaces[/-][+]node:worker_threads: worker and messaging parity cut[/+]proggeramlug commentedon May 30, 2026
Closing this "parity cut" umbrella tracker as superseded by its granular child issues.
Perry tracks Node/TypeScript parity gaps as granular, per-gap issues (the ones listed under Child Issues above) — that is the workable backlog the maintainer prefers, rather than umbrella roll-ups. Each child issue carries its own Node-vs-Perry evidence, source pointers, and test surface, and remains open and independently tracked; closing this umbrella loses no work, only the duplicate roll-up framing.
The child issues continue to be addressed by focused PRs (each PR auto-closes the specific leaf issues it fixes). If a consolidated tracker is still wanted for this module, feel free to reopen.