Skip to content

node:v8: expose serialize and deserialize round trips #3137

Description

@andrewtdiz

Summary

v8.serialize(value) and v8.deserialize(buffer) should expose Node's public V8 wire-format round-trip helpers. Perry currently has no public node:v8 namespace implementation, even though the tree contains an internal child-process V8 wire-format serde helper.

Node Behavior

A minimal Node probe shows the public serialization behavior:

const v8 = require("node:v8");
for (const value of [
  { a: 1, b: "x", c: [true, null] },
  new Map([["a", 1]]),
  new Set([1, 2]),
  123n,
  Buffer.from("abc"),
  new Date("2020-01-02T03:04:05Z"),
]) {
  const buf = v8.serialize(value);
  const out = v8.deserialize(buf);
  console.log(Buffer.isBuffer(buf), Object.prototype.toString.call(out));
}

Observed on Node v25.9.0: serialize() returns a Buffer and deserialize() reconstructs objects, maps, sets, BigInts, Buffer/Uint8Array data, dates, and undefined for covered cases. Non-serializable values such as functions, symbols, and WeakMaps throw Error; invalid deserialize inputs such as missing, null, primitives, plain objects, and arrays throw TypeError ERR_INVALID_ARG_TYPE.

Perry Behavior

docs/runtime-parity-gaps.md lists node:v8 as a gap and docs/runtime-parity.md lists v8.serialize(value) / v8.deserialize(buffer) as partial. Source search found no public node:v8 manifest/runtime implementation, while crates/perry-runtime/src/child_process/v8_serde.rs documents an internal wire shape verified against Node's v8.serialize / deserialize for child-process IPC. There is no dedicated test-files/test_parity_v8.ts or test-parity/node-suite/v8 fixture in this checkout.

Suggested PR Cut

Batch this with related issues in:
#2492 - node:v8: diagnostics and serialization parity cut

Good batch candidates:

Do not batch with:

  • unrelated modules
  • broad subsystem rewrites
  • fixes needing different test harnesses
  • promise hook APIs
  • startup snapshot APIs
  • heap snapshot stream/file output
  • profiler handle APIs

Acceptance

  • A parity/regression test proves v8.serialize() returns a Buffer and v8.deserialize() round-trips representative objects, arrays, maps, sets, BigInts, Buffers/Uint8Arrays, dates, and undefined.
  • Non-serializable values and invalid deserialize inputs produce Node-compatible errors for covered cases.
  • Public node:v8 dispatch either reuses the internal V8 serde helper where appropriate or documents any intentional wire-format limitation with a focused follow-up.
  • Related known-failure/docs/manifest entries are 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