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

RangeError: Maximum call stack size exceeded #281

Closed
hikkyu opened this issue Oct 5, 2023 · 6 comments
Closed

RangeError: Maximum call stack size exceeded #281

hikkyu opened this issue Oct 5, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@hikkyu
Copy link

hikkyu commented Oct 5, 2023

Hi there!

I work on a very big monorepo, and I encountered an issue when I run these commands with the latest version (2.30.1):

npx knip --no-gitignore

As we have multiple workspaces also tried just in one workspace (around 1000 files to analyze):
npx knip --no-gitignore --workspace apps/fr-app --exports

But I got a Heap of memory then I tried

NODE_OPTIONS=--max-old-space-size=5120 npx knip --no-gitignore --workspace apps/fr-app --exports

Also tried without npx with script in the package.json

But in any case, I always get this error:

file:///<my-project-path>/node_modules/knip/dist/typescript/getImportsAndExports.js:120
                const results = visitor(node, options);
                                ^
RangeError: Maximum call stack size exceeded
    at file:///<my-project-path>/node_modules/knip/dist/typescript/visitors/imports/jsDocType.js:4:34
    at file:///<my-project-path>/node_modules/knip/dist/typescript/visitors/index.js:4:35
    at visit (file:///<my-project-path>/node_modules/knip/dist/typescript/getImportsAndExports.js:120:33)
    at visitNode2 (/<my-project-path>/node_modules/typescript/lib/typescript.js:27926:20)
    at forEachChildInPropertyAccessExpression (/<my-project-path>/node_modules/typescript/lib/typescript.js:28495:18)
    at Object.forEachChild (/<my-project-path>/node_modules/typescript/lib/typescript.js:28019:37)
    at visit (file:///<my-project-path>/node_modules/knip/dist/typescript/getImportsAndExports.js:145:12)
    at visitNode2 (/<my-project-path>/node_modules/typescript/lib/typescript.js:27926:20)
    at forEachChildInCallOrNewExpression (/<my-project-path>/node_modules/typescript/lib/typescript.js:27975:12)
    at Object.forEachChild (/<my-project-path>/node_modules/typescript/lib/typescript.js:28019:37)

Additional information: I didn't setup a knip config file, I used the default config only.

Does it ring a bell? Tell me if you need more information 🙂

@hikkyu hikkyu added the bug Something isn't working label Oct 5, 2023
@webpro
Copy link
Collaborator

webpro commented Oct 5, 2023

No, doesn't ring a 🔔 unfortunately. Without a reproduction there isn't much I can see/do.

Most likely an infinite recursion and/or cyclic dependency.

@stackptr
Copy link

stackptr commented Oct 6, 2023

A variation of this error was caused in my project by a circular dependency. I was able to setup madge to analyze the dependency tree and fix the issue.

I wonder if there is anything useful that could be logged for debugging this scenario?

@webpro
Copy link
Collaborator

webpro commented Oct 6, 2023

I've released v2.31.0 which might fix it (probably not, though).

Otherwise I'll need a reproduction.

Using --debug probably doesn't give that much, but might at least show where in the process and/or in which workspace Knip is currently running.

@webpro
Copy link
Collaborator

webpro commented Oct 22, 2023

Closing this due to inactivity. Feel free to discuss further or open a new issue. Note that I'd need a reproduction.

@webpro webpro closed this as completed Oct 22, 2023
@lgodziejewski
Copy link

lgodziejewski commented Nov 9, 2023

I have the same issue on the newest version (2.40.0) - first I had an OoM, so I've added NODE_OPTIONS=--max-old-space-size=11776

now RangeError: Maximum call stack size exceeded 😢.

can't really give a repro, since it's a company project. I'll try to find out if there's a circular dependency, as mentioned above

@webpro
Copy link
Collaborator

webpro commented Dec 15, 2023

Knip v4 is about to mitigate some of these issues: https://knip.dev/blog/slim-down-to-speed-up (you can install and try v4 canary today). Recently added --isolate-workspaces (in v3) which may also help in certain edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants