Skip to content

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

Open

Description

@hankerboy

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)

Activity

  1. gajus commented on Jul 18, 2018

    @gajus

    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.

  2. gajus commented on Mar 1, 2019

    @gajus

    @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

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