Nx "Maximum call stack size exceeded" on project graph in CI
Nx traverses the project graph to order tasks. A cycle between projects (A depends on B depends on A) makes the traversal recurse indefinitely until the stack overflows with "Maximum call stack size exceeded".
What this error means
Nx crashes with "RangeError: Maximum call stack size exceeded" during project graph construction or task scheduling, not inside any single task.
Nx
NX Maximum call stack size exceeded
at createTaskGraph (.../nx/src/tasks-runner/...)Common causes
A circular dependency between projects
Two or more projects import each other, so the graph has a cycle and traversal never terminates.
A self-referential dependsOn chain
A dependsOn configuration creates a target-level cycle that recurses without a base case.
How to fix it
Find and break the cycle
- Run
nx graphto render dependencies and spot the loop. - Break the import cycle by extracting shared code to a third library.
- Re-run so the graph becomes acyclic.
Terminal
nx graph --file=graph.htmlEnforce no circular deps in lint
The module boundaries rule can flag circular dependencies so they fail lint before they overflow the graph.
.eslintrc.json
"@nx/enforce-module-boundaries": ["error", { "allowCircularSelfDependency": false }]How to prevent it
- Render
nx graphin review to catch new cycles. - Extract shared code into a leaf library instead of cross-importing.
- Enable the module boundaries lint rule to block cycles early.
Related guides
Nx "enforce-module-boundaries" lint violation in CIFix Nx "@nx/enforce-module-boundaries" lint errors in CI - an import crosses a project tag or type boundary t…
Nx "Failed to process project graph" in CIFix Nx "Failed to process project graph" in CI - Nx could not build the project graph because a config, plugi…
Turborepo "cyclic dependency detected" in CIFix Turborepo "cyclic dependency detected" in CI - two packages or tasks depend on each other, so turbo canno…