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

fix: RangeError: Maximum call stack size exceeded error at querying.find when children size is too large #1281

Closed

Conversation

yoshitaka-ogata
Copy link
Contributor

I encounter the error RangeError: Maximum call stack size exceeded at result.push(...children); in the querying.find method when the children size is too large.
children.slice solve the above error.

@fb55
Copy link
Owner

fb55 commented Mar 24, 2023

Interesting issue. Testing this myself, for NodeJS the magic number seem to be 105,193 items that are still spreadable (so the number in this PR is quite a bit too low). I can't find an official reference for this limitation though, as all specs make it seem like the number is infinite. Also, spreading into an array doesn't have the same limitation.

@yoshitaka-ogata
Copy link
Contributor Author

Thank you for checking!
I checked the push method input limitation with simple code with my environment as follows.

Environment:

  • MacBook Pro M1 2020
  • Memory 16GB
  • OS 13.2
  • node v16.13.2
result = [];
// uint8 array
arr = new Uint8Array(120633); // OK
// arr = new Uint8Array(120634); // RangeError: Maximum call stack size exceeded
result.push(...arr);

// string array
arr = Array(120633).fill('1234567890'); // OK
// arr = Array(120634).fill('1234567890'); // RangeError: Maximum call stack size exceeded
result.push(...arr);

The input array length max size is 120633 in my env. Not depends on byte size.

BTW, node 32bit stack size is half of 64 bit according to https://stackoverflow.com/a/20748130.
So, I think chunksize is 100,000 / 2 = 50,000 is better for any environment. I'll update the value to 50000.

@fb55
Copy link
Owner

fb55 commented Apr 29, 2023

Hi @yoshitaka-ogata, I've tackled this by switching to a better querying algo in #1349. I've included your test case, so thanks a lot for opening this PR!

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

Successfully merging this pull request may close these issues.

None yet

2 participants