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
- Stream large data instead of building one string
- Fix runaway loops
- Paginate/chunk exports
Detailed fix by platform
Node.js
- Use streams (fs.createWriteStream, stream.pipeline) for large outputs
How to diagnose
- Size — How large is the data?
- 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026