bun icon indicating copy to clipboard operation
bun copied to clipboard

`SegmentationFault at 3` when parsing a large JSON file

Open lawrencecchen opened this issue 2 years ago • 2 comments

–––– bun meta ––––
Bun v0.0.83 macOS Silicon 21.4.0
AutoCommand: public_folder
Elapsed: 598ms | User: 29ms | Sys: 34ms
RSS: 54.62MB | Peak: 54.62MB | Commit: 0.27GB | Faults: 732
–––– bun meta ––––

Reproduction: https://github.com/lawrencecchen/stripe-sync/tree/1a49d8cf81ab573d39e823f8eef06d717e3efdd6

bun index.ts

lawrencecchen avatar Jun 14 '22 08:06 lawrencecchen

thanks for reporting

Jarred-Sumner avatar Jun 16 '22 22:06 Jarred-Sumner

I think the issue is in the console.log implementation. Seems to stack overflow on large objects

If you do JSON.stringify(object) it works

Jarred-Sumner avatar Jun 16 '22 23:06 Jarred-Sumner

Tested on MacOS with 0.2.2, looks like this issue is fixed.

const response = await fetch(
  "https://raw.githubusercontent.com/json-iterator/test-data/master/large-file.json",
  {
    headers: {
      "Accept-Encoding": "identity",
    }  
  }
);
const body = await response.text();
const json = JSON.parse(body);
console.log(json);

Electroid avatar Nov 01 '22 19:11 Electroid