Skip to content

node:worker_threads: implement MessageChannel ports and receiveMessageOnPort #3157

Closed

Description

@andrewtdiz

Summary

node:worker_threads should export connected MessageChannel / MessagePort objects plus receiveMessageOnPort. Perry currently has only a generic postMessage manifest entry and no module-level port/channel object implementation.

Node Behavior

On Node v25.9.0, new MessageChannel() returns object-valued port1 and port2. Ports expose function-valued postMessage, close, start, ref, unref, and hasRef. Posting on port1 can be consumed synchronously with receiveMessageOnPort(port2), which returns an object shaped like { message: value }; event listeners on port2 also receive later messages, and closing ports emits a close event.

Perry Behavior

docs/runtime-parity-gaps.md lists receiveMessageOnPort, new MessageChannel, channel.port1, channel.port2, and most MessagePort methods/events as missing. test-files/test_parity_worker_threads.ts only shape-probes the channel and port methods. crates/perry-api-manifest/src/entries.rs has a generic worker_threads.postMessage receiver but no MessageChannel, MessagePort, or receiveMessageOnPort entries; crates/perry-stdlib/src/worker_threads.rs only models a synthetic parentPort handle.

Suggested PR Cut

Batch this with related issues in:
#3307 - node:worker_threads: message channels and clone markers parity cut

Good batch candidates:

Do not batch with:

  • unrelated modules
  • broad subsystem rewrites
  • fixes needing different test harnesses
  • Web Locks APIs
  • worker heap/profile diagnostics
  • full Worker constructor execution unless shared transport queues are introduced in the same PR

Acceptance

  • A parity/regression test constructs new MessageChannel() from node:worker_threads and verifies port1 / port2 and method shapes.
  • port.postMessage delivers structured data to the opposite port via both receiveMessageOnPort and message events for covered cases.
  • close, start, ref, unref, and hasRef expose Node-compatible behavior for covered cases.
  • Related known-failure/docs/manifest entries are updated if touched.

Activity

  1. added a commit that references this issue on May 31, 2026
    61f0716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions