Error Reference › JavaScript
JavaScript

Maximum call stack size exceeded

A function called itself (directly or indirectly) without a stopping condition — infinite recursion.

What it looks like

Uncaught RangeError: Maximum call stack size exceeded
    at walk (tree.js:8:5)
    at walk (tree.js:10:7)
    at walk (tree.js:10:7)

What does "Maximum call stack size exceeded" mean?

Thrown when function calls nest deeper than the engine allows — almost always endless recursion. The stack trace shows the same function (or pair of functions) repeating, which tells you where the loop is.

What causes "Maximum call stack size exceeded"?

  • Recursion with no/incorrect base case.
  • Two functions calling each other in a loop.
  • A reactive update that re-triggers itself.

How do I confirm the cause?

  1. Look at the repeating frames in the stack trace; the function that keeps calling itself is the one to fix.
  2. Check the base case — the condition that should stop the recursion is missing, wrong or never reached for this input.
  3. In frameworks, look for state updates inside render or effects that trigger themselves, and for getters or setters that call themselves.

How do I fix "Maximum call stack size exceeded"?

  • Add or fix the base case that stops the recursion.
  • Trace the repeated frames in the stack.
  • Break the update cycle (e.g. guard against re-entrancy).

How do I stop it happening again?

  • Write the stopping condition first when writing recursive code, and test it with edge cases.
  • For deep data such as big trees, use an explicit stack or queue (a loop) instead of recursion.
Got a different error? Paste it into the Explain This Error tool → Identifies the family and the fix — runs locally, nothing uploaded.

Related errors