Skip to content

Improve node:buffer slice/subarray shared backing-store parity #1205

Closed

Description

@TheHypnoo

Context

The granular node:buffer parity suite covers deterministic slice and subarray range behavior, but it still avoids Node's shared-memory mutation semantics.

Gap

In Node, buf.slice() and buf.subarray() return views over the same backing memory. Mutating the returned view mutates the original buffer, and mutating the original buffer is visible through the view.

Perry currently uses copy-like buffer results for the passing subset.

Desired behavior

  • const s = buf.slice(1, 3); s[0] = 0x61; updates buf[1].
  • const v = buf.subarray(1, 3); buf[1] = 0x62; updates v[0].
  • Existing Node-compatible range handling should be preserved.

Suggested implementation notes

This likely needs a Buffer view representation rather than another copy-only allocation path. Options include extending BufferHeader with backing pointer/offset metadata or introducing a separate view header that all buffer read/write/search methods understand.

Parity tests to add

  • test-parity/node-suite/buffer/copy-slice/slice-shared-mutation.ts
  • test-parity/node-suite/buffer/copy-slice/subarray-shared-mutation.ts

Validation

  • ./run_parity_tests.sh --suite node-suite --module buffer

Activity

  1. added
    parityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem
    on May 20, 2026
  2. added a commit that references this issue on May 21, 2026
    0553adf
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

    parityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions