invalid string length 🟨 JavaScript

RangeError: Invalid string length

A string grew beyond the engine’s maximum length — usually runaway concatenation or huge JSON.stringify output.

Seen on: JavaScript

Meaning

V8 strings max out around 512 MB–1 GB. Infinite loops appending text or stringifying massive objects hit the limit.

Common causes

  • Infinite loop concatenating
  • JSON.stringify of very large data
  • Reading a huge file into one string

⚡ Quick fix

  1. Stream large data instead of building one string
  2. Fix runaway loops
  3. Paginate/chunk exports

Detailed fix by platform

Node.js

  1. Use streams (fs.createWriteStream, stream.pipeline) for large outputs

How to diagnose

  1. Size — How large is the data?
  2. Loop — Is something appending forever?

🧠 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.