Common causes
- A recursive function is missing its base case (the condition that stops the recursion)
- Two functions are calling each other in an infinite loop
- JSON.stringify is called on an object that contains circular references
- An event handler is accidentally triggering itself
How to fix it
- Review your recursive function and make sure it has a valid base case that terminates the recursion
- For circular JSON: use JSON.stringify with a replacer, or use the 'flatted' package
- Add logging at the top of the recursive function to trace how deep it goes
- Consider converting deep recursion to an iterative loop with an explicit stack
Example
RangeError: Maximum call stack size exceeded
at factorial (/home/user/app.js:3:10)
at factorial (/home/user/app.js:5:12)
at factorial (/home/user/app.js:5:12)A recursive factorial function called with a negative number — the base case is never reached
Have a different error?
Paste any error message into the Error Translator to get an instant explanation.
