Skip to content

JSON.parse(blob, reviver) with lazy-tape top-level array: reviver not called on elements #1424

Description

@proggeramlug

Summary

test_json_lazy_reviver (a regression-catcher for PERRY_JSON_TAPE=1) crashes / exits with no output. The test:

```ts
const blob = '[0,1,2,...,299]'; // 300-element top-level array
let calls = 0;
const parsed = JSON.parse(blob, (_k, v) => { calls++; return typeof v === 'number' ? v + 1 : v; });
console.log('len', parsed.length); // expect 300
console.log('first', parsed[0]); // expect 1
console.log('last', parsed[299]); // expect 300
console.log('calls', calls); // expect 301 (300 elements + root)
```

Observed (v0.5.1024 main HEAD)

Perry produces ZERO output lines (vs Node's 4). The lazy-tape parse path doesn't invoke the reviver on top-level-array elements, and something in the materialisation path is exiting the process before the console.logs fire.

Repro

```
./target/release/perry test-files/test_json_lazy_reviver.ts
```

Suspected root cause

Likely fallout from the recent JSON lazy-tape / GC checkpoint work (#1146 made copied minor default-eligible; #1235 / #1324 ported the GC checkpoint runtime). When the lazy top-level array is force-materialised by the reviver path, either:

  1. The reviver is skipped entirely on lazy tape decodes, or
  2. The materialise+reviver path SIGSEGVs and aborts before any of the console.logs flush.

Disposition for v0.5.1025

test_json_lazy_reviver skip-listed in test-parity/known_failures.json under category bug-open with this issue number. Flips to PASS when the lazy-tape reviver dispatch lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regressionparityCompatibility 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