Skip to content

node:worker_threads: implement transfer and clone marker helpers #3159

Closed

Description

@andrewtdiz

Summary

node:worker_threads should implement transfer/clone marker helpers that affect structured clone behavior: markAsUntransferable, isMarkedAsUntransferable, and markAsUncloneable. Perry currently has no marker implementation.

Node Behavior

On Node v25.9.0, isMarkedAsUntransferable(new ArrayBuffer(8)) is initially false; markAsUntransferable(buffer) returns undefined; and isMarkedAsUntransferable(buffer) becomes true. If the marked buffer is later included in a MessagePort.postMessage(value, [buffer]) transfer list, Node throws a DataCloneError with code 25 and keeps the buffer undetached. markAsUncloneable(object) returns undefined, and posting that object through a port throws a DataCloneError. Primitive inputs are accepted for marking and isMarkedAsUntransferable(primitive) returns false.

Perry Behavior

docs/runtime-parity.md lists markAsUntransferable, isMarkedAsUntransferable, and markAsUncloneable; docs/runtime-parity-gaps.md marks them missing. test-files/test_parity_worker_threads.ts shape-probes these helpers but avoids postMessage side effects. Source search found no manifest/runtime/stdlib entries for the marker helpers or structured-clone marker state.

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
  • Worker constructor execution unless transfer-list plumbing is already being touched

Acceptance

  • A parity/regression test proves markAsUntransferable changes isMarkedAsUntransferable for object values and returns undefined.
  • Posting a marked ArrayBuffer in a transfer list throws a Node-compatible DataCloneError and leaves the buffer undetached for covered cases.
  • markAsUncloneable causes postMessage structured cloning to reject the marked object with a Node-compatible DataCloneError.
  • Primitive input behavior matches Node 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