Skip to content
Latchkey

Node "RangeError: Maximum call stack size exceeded" During Build - Fix in CI

A "Maximum call stack size exceeded" during a build is a stack overflow - something recursed without a base case. In bundlers it is usually a circular dependency, a self-referential config, or a plugin bug.

What this error means

The build crashes with RangeError: Maximum call stack size exceeded, often deep inside the bundler or a plugin rather than your application code. It is deterministic - it fails the same way each run.

Build output
RangeError: Maximum call stack size exceeded
    at Object.resolve (.../webpack/lib/Resolver.js)
    at resolve (.../webpack/lib/Resolver.js)
    at resolve (.../webpack/lib/Resolver.js)
    ... (repeating frames)

Common causes

A circular dependency or alias loop

Modules importing each other in a cycle, or a resolver alias that points back at itself, makes the bundler recurse until the stack overflows.

A buggy or misconfigured plugin/transform

A plugin that recursively processes the same node, or a config that nests itself, produces unbounded recursion during the build.

How to fix it

Find and break the recursion

Locate the cycle from the repeating frames and break it.

Terminal
# surface circular imports
npx madge --circular src/
# then refactor the cycle, or fix the self-referential alias/config

Isolate the offending input

  1. Read the repeating stack frames to see which tool/plugin recurses.
  2. Bisect by disabling plugins/aliases until the overflow stops.
  3. Check for a config object that references itself.

How to prevent it

  • Lint for circular dependencies (e.g. madge) in CI.
  • Keep resolver aliases non-self-referential.
  • Pin and vet build plugins for known recursion bugs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →