Skip to content

node:buffer: Buffer backing properties are missing on Buffer instances #3386

Description

@andrewtdiz

Summary

Node Buffer instances expose typed-array-style backing properties such as .buffer, .byteOffset, and legacy .parent. Perry's Buffer byte APIs pass the granular suite, but these backing properties currently diverge.

Node Behavior

./run_parity_tests.sh --filter test_parity_buffer exercises:

const ip = Buffer.from([0x10, 0x20, 0x30]);
console.log("buf.buffer instanceof ArrayBuffer:", ip.buffer instanceof ArrayBuffer);

const ipSlow = Buffer.allocUnsafeSlow(4);
ipSlow.fill(0);
console.log("buf.byteOffset (slow):", ipSlow.byteOffset);
console.log("buf.parent typeof:", typeof ipSlow.parent);

Node output:

buf.buffer instanceof ArrayBuffer: true
buf.byteOffset (slow): 0
buf.parent typeof: object

Perry Behavior

The same targeted parity run currently reports:

buf.buffer instanceof ArrayBuffer: false
buf.byteOffset (slow): undefined
buf.parent typeof: undefined

The granular ./run_parity_tests.sh --suite node-suite --module buffer run passed 124/124, so the bytes, reads/writes, encoding, search, and slice/subarray behavior are healthy. This gap is specifically the Buffer instance backing-property surface.

Suggested PR Cut

Batch this with related issues in:
node:buffer: module namespace and backing property parity cut

Good batch candidates:

  • the leaf for namespace-bound Blob/File constructors

Do not batch with:

  • unrelated Buffer byte/numeric API work
  • Blob/File constructor coercion behavior unless touching the same module-property lowering path
  • ArrayBuffer/DataView rewrites beyond the backing object needed for Buffer parity

Acceptance

  • parity/regression test proves Buffer.from(...).buffer instanceof ArrayBuffer matches Node
  • parity/regression test proves Buffer.allocUnsafeSlow(...).byteOffset matches Node for the deterministic slow-buffer case
  • parity/regression test covers legacy parent shape at least to Node's observable typeof level
  • existing granular buffer suite remains green
  • related known-failure/docs/manifest entries updated if touched

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