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

Converting a Seq to a list causes RangeError (max call size exceeded) #1915

Open
phou-patreon opened this issue Dec 9, 2022 · 1 comment
Labels

Comments

@phou-patreon
Copy link

What happened

Converting a Seq to a list on anything remotely large (even a Seq with 1000 items seems to be enough) causes a max call size exceeded error.

After tracing through the code a bit, it seems to be happening because the implementation of flatDeep is unnecessarily recursive (it iterates recursively in the default case).

How to reproduce

This codesandbox repros the issue: https://codesandbox.io/s/stoic-brook-zlzcs6?file=/src/index.js

@jdeniau jdeniau added the bug label Dec 12, 2022
@bdurrer
Copy link
Contributor

bdurrer commented Dec 20, 2022

The documentation and the fact that the sample had to reassign meta = meta.concat(i) suggest that this sample in fact creates 1000 nested sequences, which are lazily linked until toList forces them to materialize.

BTW a better option for bulk operations is withMutation, e.g.

List().withMutations((mutable) => {
  for (let i = 0; i < 10000; ++i) {
    mutable.concat(i);
  }
});

of course, the Seq crashing is bad nonetheless

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

No branches or pull requests

3 participants