webpro-nl / knip

✂️ Find unused files, dependencies and exports in your JavaScript and TypeScript projects. Knip it before you ship it!
https://knip.dev
ISC License
6.72k stars 158 forks source link

RangeError: Maximum call stack size exceeded #97

Closed thomas-w-grant closed 1 year ago

thomas-w-grant commented 1 year ago

I am running npx knip with no config on a nx workspace.

I am getting the following error:

Analyzing source files...
file:///Users/tomgrant/.nvm/versions/node/v16.17.0/lib/node_modules/knip/dist/dependency-deputy.js:108
                if (referencedDependencies?.has(dependency))
                                            ^

RangeError: Maximum call stack size exceeded
    at Set.has (<anonymous>)
    at isUnreferencedDependency (file:///Users/tomgrant/.nvm/versions/node/v16.17.0/lib/node_modules/knip/dist/dependency-deputy.js:108:45)
    at file:///Users/tomgrant/.nvm/versions/node/v16.17.0/lib/node_modules/knip/dist/dependency-deputy.js:123:70
    at Array.find (<anonymous>)
    at isUnreferencedDependency (file:///Users/tomgrant/.nvm/versions/node/v16.17.0/lib/node_modules/knip/dist/dependency-deputy.js:123:46)
    at file:///Users/tomgrant/.nvm/versions/node/v16.17.0/lib/node_modules/knip/dist/dependency-deputy.js:123:70
    at Array.find (<anonymous>)
    at isUnreferencedDependency (file:///Users/tomgrant/.nvm/versions/node/v16.17.0/lib/node_modules/knip/dist/dependency-deputy.js:123:46)
    at file:///Users/tomgrant/.nvm/versions/node/v16.17.0/lib/node_modules/knip/dist/dependency-deputy.js:123:70
    at Array.find (<anonymous>)
webpro commented 1 year ago

Looks like some infinite recursion, not pretty. Maybe some kind of triangle between peer dependencies. Not sure I can reproduce with more information. For starters, just to be sure:

Normally I would ask to run with --debug but I'm not sure that will reveal anything useful.

webpro commented 1 year ago

:rocket: This issue has been resolved in v2.10.0. See Release 2.10.0 for release notes.

webpro commented 1 year ago

I think I found the culprit: circular peer dependencies indeed. Hopefully no more infinite recursion :)

thomas-w-grant commented 1 year ago

Sorry I abandoned you. : (

I got pulled to work on something else and am just getting back to this project. Thank you.