PlainError

RangeError: Maximum call stack size exceeded

Last checked 2026-11-11 · 3 fixes · reviewed answer

TL;DRThis JavaScript error occurs when a function calls itself (or a chain of functions calls) so many times without stopping that the browser or runtime runs out of space to track the calls.

Most likely cause: Infinite recursion in a function with no proper base case or exit condition

Try first: Open the browser or Node.js console and look at the stack trace

Likely causes

  1. Infinite recursion in a function with no proper base case or exit conditionmost likely
  2. Very deep but finite recursion that exceeds the engine's stack limitpossible
  3. Accidental self-referential data structures or event listeners that trigger each otherless likely

How to fix it

Safest first: SafeChanges settingsDangerous
  1. Open the browser or Node.js console and look at the stack traceSafe

    The error message usually shows the exact function and line that is calling itself repeatedly.

  2. Add a base case or depth limit to any recursive function you recently changedChanges settings

    Make sure every recursive function has a clear condition that stops further calls, such as checking if an array is empty or a counter has reached a limit.

  3. Replace recursion with iteration (a loop) for the problematic function if possibleChanges settings

    Loops use far less stack space than repeated function calls.

If that didn't fix it

Use a debugger to step through the function and watch how many times it calls itself before the error.

When to see a technician

If the error occurs inside a library or framework you did not write, ask the maintainers or a developer familiar with that code.

Quick answers

What does RangeError: Maximum call stack size exceeded mean?
This JavaScript error occurs when a function calls itself (or a chain of functions calls) so many times without stopping that the browser or runtime runs out of space to track the calls.
What causes RangeError: Maximum call stack size exceeded?
Infinite recursion in a function with no proper base case or exit condition. (most likely) Very deep but finite recursion that exceeds the engine's stack limit. (possible) Accidental self-referential data structures or event listeners that trigger each other. (less likely)
How do I fix RangeError: Maximum call stack size exceeded?
Try these in order, safest first: 1. Open the browser or Node.js console and look at the stack trace. 2. Add a base case or depth limit to any recursive function you recently changed. 3. Replace recursion with iteration (a loop) for the problematic function if possible.
What if that didn't fix it?
Use a debugger to step through the function and watch how many times it calls itself before the error.
When should I see a technician?
If the error occurs inside a library or framework you did not write, ask the maintainers or a developer familiar with that code.
Did this fix it? Report a problem

Related errors

All Coding errors →