Skip to content

RangeError: Invalid array length #208

@AmitMY

Description

@AmitMY

I am trying to parse an a float array.
Normally, this code works, however, I now have one huge file (400MB of file), and I want to start reading it.

    const dataParser = newParser()
        .array("data", {
            type: "floatle",
            length: dataLength // 82,272,642
        })
        .saveOffset('dataLength');

    const data = dataParser.parse(buffer);

As you can see, I am trying to parse an array with 82 million entries, which is less than the 2147483647 limit in javascript, however, I am getting the following error:

Uncaught (in promise) RangeError: Invalid array length
at Array.push ()
at Parser.eval [as compiled]

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length

Additional information

Manual experimentation finds that the limit is somewhere between 50,100,000 and 50,500,000.

(related to sign/translate#44)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions