RangeError 🟨 JavaScript

RangeError: Maximum call stack size exceeded

A function called itself (directly or indirectly) too many times — usually infinite recursion.

Seen on: JavaScript

Meaning

Each function call adds a frame to the call stack; when there are too many frames the engine throws. The cause is almost always recursion without a working base case, or two functions/setters/watchers calling each other.

Common causes

  • Recursive function without a correct base case
  • Setter/getter that sets/reads its own property
  • Two functions or event handlers triggering each other
  • JSON.stringify or deep clone on a circular structure (some libraries)
  • React/Vue watchers updating the value they watch

⚡ Quick fix

  1. Look at the repeating frames in the stack trace
  2. Add/fix the base case of the recursion
  3. In setters, store into a different backing field (this._value)
  4. Convert deep recursion into an iterative loop

Detailed fix by platform

JavaScript

  1. Setter recursion:
    javascript
    class User {
      set name(v) { this.name = v; }   // ❌ calls the setter again forever
      set name(v) { this._name = v; }  // ✅
      get name() { return this._name; }
    }

How to diagnose

  1. Stack — Which functions repeat?
  2. Base case — Does recursion ever stop?
  3. Side effects — Do handlers trigger each other?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.