# RangeError: “Maximum call stack size exceeded”

> RangeError: Maximum call stack size exceeded. Find the function that calls itself, add a base case, fix setters that set themselves, don’t spread huge arrays.

Canonical: https://app369.com/fix/maximum-call-stack-size-exceeded/
Last updated: 2026-11-08

The browser or Node.js stops with RangeError: Maximum call stack size exceeded (InternalError: too much recursion in Firefox). Every function call takes a slot on the call stack, and something made so many nested calls that the stack ran out. Almost always one function, or a pair of functions, keeps calling itself without stopping.

**Short answer**

Open the stack trace: the same function name repeating over and over is the loop. Give recursion a base case that is always reached. Check setters and getters that read or assign their own property (set name(v) { this.name = v } calls itself). Check two functions or event handlers that call each other. For very deep data, use a loop instead of recursion. And don’t spread huge arrays into function arguments (Math.max(...bigArray), arr.push(...other)), which can hit the same limit.

## **Why the stack overflows, and the fix**

1. 01 ### **Recursion without a working base case**
  > “When there are too many function calls, or a function is missing a base case, JavaScript will throw this error.” [**MDN, RangeError: Maximum call stack size exceeded**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Too_much_recursion) A recursive function must stop at some input. If the stop condition is missing, wrong, or never reached (for example the argument never shrinks), the calls never end.```
function sumTo(n) {
  if (n <= 0) return 0;   // base case
  return n + sumTo(n - 1); // n shrinks every call
}
```
2. 02 ### **A setter or getter that uses its own name** Inside set name(value), writing this.name = value calls the setter again, forever. The same happens with a getter that reads this.name. Store the value in a different field.```
class User {
  #name = '';
  get name() { return this.#name; }
  set name(value) { this.#name = value.trim(); }
}
```
3. 03 ### **Two functions or handlers that call each other** A change handler that updates a value, which fires the change handler again; a toString or toJSON that formats an object that contains itself; a store subscription that writes to the store. Find the pair in the stack trace and break the cycle with a check or a flag.```
function onChange(value) {
  if (value === current) return; // stop the echo
  current = value;
  input.value = value;
}
```
4. 04 ### **Spreading a huge array into arguments** Math.max(...arr), arr.push(...other) and fn.apply(null, arr) pass every element as a separate argument. With hundreds of thousands of items that can exceed the stack. Use reduce or a loop instead.```
const max = values.reduce((m, v) => (v > m ? v : m), -Infinity);
for (const item of other) arr.push(item);
```

Checked against the vendor’s docs on November 8, 2026: [MDN: InternalError: too much recursion / RangeError: Maximum call stack size exceeded](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Too_much_recursion).

## **Rather hand it over?**

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

- [from $450**App Fix Ticket**One reproducible bug in an existing mobile or web app, diagnosed and fixed.**See scope and start**](https://app369.com/fixed-price/flutter-firebase-bug-fix/)
- [from $450**AI-Built App Rescue**A Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.****No issues worth fixing, no charge.**** If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.**See scope and start**](https://app369.com/fixed-price/ai-app-rescue/)

Related: [**React “Maximum update depth exceeded”**](https://app369.com/fix/react-maximum-update-depth-exceeded/) · [**“Converting circular structure to JSON”**](https://app369.com/fix/converting-circular-structure-to-json/) · [**Node.js “JavaScript heap out of memory”**](https://app369.com/fix/javascript-heap-out-of-memory/)

Questions

## **More on this error**

<details>

<summary>**Can I just increase the stack size? **+</summary>

Node.js has a --stack-size flag, but raising it can crash the process instead of throwing a catchable error, and browsers have no such setting. Fix the recursion or make it a loop.

</details>

<details>

<summary>**Is this the same as React’s “Maximum update depth exceeded”? **+</summary>

No. That one is React stopping a render loop, usually setState in useEffect or during render. This one is plain JavaScript running out of call stack.

</details>

<details>

<summary>**Can you fix it for me? **+</summary>

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

</details>

A different error?

## **Describe it and get a written quote**

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.

[**Describe your problem **→](https://app369.com/contact/) [**All fixes**](https://app369.com/fix/)