You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug report
Computing usages recursively causes infinite loop when type declarations are cyclic.
After spending a few hours attempting to debug this myself in the types-usage-evaluator file, I've had no luck.
I personally have valid cyclic types in a GQL backend I'm running, but I've also been able to replicate the issue with another more popular package: React FontAwesome.
I'm not entirely familiar with how other tools such as TSC deal with this issue, my first instinct is to run a check on whether a Type/Interface contains itself at any other point in the tree and exit the loop, but unsure if that's the correct approach.
Here's a repo that displays this issue in a very simple setup:
I'm using Bun in this example but any runtime/package manager should have this issue.
To reproduce the issue just clone that repo and run bun i && bun run build.mjs
Thanks!
Actual output
RangeError: Maximum call stack size exceeded.
at computeUsagesRecursively (/home/project/node_modules/dts-bundle-generator/dist/types-usage-evaluator.js:155:13)
at computeUsageForNode (/home/project/node_modules/dts-bundle-generator/dist/types-usage-evaluator.js:55:21)
at visitNodes (/home/project/node_modules/typescript/lib/typescript.js:27934:24)
at forEachChildInSourceFile (/home/project/node_modules/typescript/lib/typescript.js:28556:18)
at forEachChild (/home/project/node_modules/typescript/lib/typescript.js:28019:37)
at computeUsages (/home/project/node_modules/dts-bundle-generator/dist/types-usage-evaluator.js:40:13)
at new TypesUsageEvaluator (/home/project/node_modules/dts-bundle-generator/dist/types-usage-evaluator.js:10:9)
at generateDtsBundle (/home/project/node_modules/dts-bundle-generator/dist/bundle-generator.js:21:33)
The text was updated successfully, but these errors were encountered:
It seems it might be the issue with Bun itself. Well, technically it is just the difference between runtimes. Apparently nodejs has higher limits for the callstack size than bun, thus you see this error.
I just cut a ticket to bun oven-sh/bun#10270 just in case if they want to sync/increase this value, but regardless I'll try to fix it from my size because even if they will do that, there is a cache to hit this issue even with a higher limit with more complex types.
Bug report
Computing usages recursively causes infinite loop when type declarations are cyclic.
After spending a few hours attempting to debug this myself in the
types-usage-evaluator
file, I've had no luck.I personally have valid cyclic types in a GQL backend I'm running, but I've also been able to replicate the issue with another more popular package: React FontAwesome.
I'm not entirely familiar with how other tools such as TSC deal with this issue, my first instinct is to run a check on whether a Type/Interface contains itself at any other point in the tree and exit the loop, but unsure if that's the correct approach.
Here's a repo that displays this issue in a very simple setup:
https://github.com/KieranTH/DTS-Bundle-Circular-Issue
I'm using Bun in this example but any runtime/package manager should have this issue.
To reproduce the issue just clone that repo and run
bun i && bun run build.mjs
Thanks!
Actual output
The text was updated successfully, but these errors were encountered: