Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parcing large file with only one row(40Mb json file) #43

Open
hankerboy opened this issue Oct 20, 2017 · 2 comments
Open

Error parcing large file with only one row(40Mb json file) #43

hankerboy opened this issue Oct 20, 2017 · 2 comments

Comments

@hankerboy
Copy link

When I try to do it from cli
Error: File 'messages.json' does not exist
When I try to do it from node

directory/node_modules/prettyjson/lib/prettyjson.js:167
      output.push.apply(
                  ^

RangeError: Maximum call stack size exceeded
    at directory/prettyjson/lib/prettyjson.js:167:19
    at Array.forEach (<anonymous>)
    at renderToArray (directory/node_modules/prettyjson/lib/prettyjson.js:145:36)
    at Object.render (directory/node_modules/prettyjson/lib/prettyjson.js:210:10)
    at Object.<anonymous> (directory/test.js:14:24)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
@gajus
Copy link

gajus commented Jul 18, 2018

Here is a test case to reproduce the issue:

it('should not trigger maximum call stack size exceeded error', function () {
  const subject = {
    data: []
  };

  let index = 1000000;

  while (index--) {
    subject.data.push(index);
  }

  prettyjson.render(subject);
});

The solution would be to rewrite renderToArray to use a loop instead of recursion.

@gajus
Copy link

gajus commented Mar 1, 2019

@rafeca Any chance of fixing this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants