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

Maximum call stack size exceeded #37

Open
aikar opened this issue Nov 9, 2019 · 10 comments · May be fixed by #39
Open

Maximum call stack size exceeded #37

aikar opened this issue Nov 9, 2019 · 10 comments · May be fixed by #39

Comments

@aikar
Copy link

aikar commented Nov 9, 2019

RangeError: Maximum call stack size exceeded
at node_modules/klaw/src/index.js:45:23
at go$readdir$cb (node_modules/graceful-fs/graceful-fs.js:187:14)
at FSReqWrap.oncomplete (fs.js:135:15)

version 2.1.1 but nothing in new version relates here.

I have a folder with 200k+ files in it that crashes klaw.

        const crawl = async (subdir: string, cb) => {
            const done = resolvable();
            klaw(path.join(dir, subdir), {
                filter: (item) => {
                    return item.endsWith(".job");
                }
            }).on('data', (item) => {
                cb(item.path);               
            }).on('end', () => done.resolve());
            await done;
        };
@aikar
Copy link
Author

aikar commented Jan 15, 2020

Ended up switching to https://www.npmjs.com/package/walk due to this bug.

@oorestisime
Copy link

Hey @jprichardson how would you feel changing this https://github.com/jprichardson/node-klaw/blob/master/src/index.js#L53 to not use apply? Either spreading the array or concat will avoid stack size range error and also probably would be faster?

i think concat might probably be the first solution but then array will need to be mutated

@jprichardson
Copy link
Owner

Certainly. Should modernize the code as well (separate PR)

@oorestisime
Copy link

Thanks for the quick response. PR opened :)

@jprichardson
Copy link
Owner

@oorestisime would you be willing to put a test in place verifying that this actually fixes the problem? Thanks.

@oorestisime
Copy link

I can take a look yeah. but this means adding a test with more than 200k files or so (haven't looked how the tests are )

@jprichardson
Copy link
Owner

Couldn't a test harness be used to generate the files?

@mhahn-sighthoundlabs
Copy link

We experienced this problem with around 60K files in a folder.

@oorestisime
Copy link

hey i am back at this. i completely forgot about it. what are our options here. change seems fairly trivial imho

@pea
Copy link

pea commented Apr 19, 2022

@oorestisime's fix it working for us with 260k pages.

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 a pull request may close this issue.

5 participants