Skip to content

Commit d9adc31

Browse files
Copilotitsdouges
andauthored
Fix: Prevent ts-morph call stack errors with compiler options (#369)
* Initial plan * Add error handling for ts-morph maximum call stack errors Co-authored-by: itsdouges <[email protected]> * Clean up unintended changes to test mock file Co-authored-by: itsdouges <[email protected]> * Fix: Handle ts-morph call stack errors gracefully Co-authored-by: itsdouges <[email protected]> * Prevent stack overflow by limiting TypeScript import resolution depth Co-authored-by: itsdouges <[email protected]> * Revert test mock changes and add changeset Co-authored-by: itsdouges <[email protected]> * Remove all test code from box.tsx mock file Co-authored-by: itsdouges <[email protected]> * Fix lint errors - sort compiler option keys alphabetically Co-authored-by: itsdouges <[email protected]> * Clean box.tsx - remove test artifacts added during test runs Co-authored-by: itsdouges <[email protected]> * Addressing PR comments Co-authored-by: itsdouges <[email protected]> * Revert test code from box.tsx mock file Co-authored-by: itsdouges <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: itsdouges <[email protected]>
1 parent 8d5e582 commit d9adc31

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@triplex/server": patch
3+
---
4+
5+
Prevent maximum call stack exceeded errors by limiting TypeScript import resolution depth. Added `skipLibCheck` and `maxNodeModuleJsDepth` compiler options to prevent infinite loops when resolving complex import graphs.

packages/@triplex/server/src/ast/project.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export function _createProject({
4545
compilerOptions: {
4646
// This ensures that even if a project is misconfigured we can still infer types from JS.
4747
allowJs: true,
48+
// Limit the depth TypeScript searches through node_modules to prevent stack overflow
49+
// errors caused by deeply nested or circular package.json references.
50+
maxNodeModuleJsDepth: 0,
4851
// This forces the module resolution to use the bundler algorithm. This fixes @react-three/uikit for use in Triplex
4952
// without userland needing to fix it.
5053
// See: https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#--moduleresolution-bundler
@@ -53,6 +56,9 @@ export function _createProject({
5356
// node_modules. We set this to false to ensure that consumers of triplex never run into
5457
// this.
5558
preserveSymlinks: false,
59+
// Skip type checking of declaration files to reduce recursive imports and prevent
60+
// maximum call stack errors when TypeScript walks complex node_modules structures.
61+
skipLibCheck: true,
5662
// We turn this off so we can effectively ignore null and undefined when fetching
5763
// the types of jsx elements. This makes everything much easier to reason about.
5864
// Meaning instead of us having to manually iterate and ignore type values they just

0 commit comments

Comments
 (0)