Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

RangeError: Invalid string length --- it should be saying Out Of Memory #14170

Closed
scottstensland opened this issue Mar 26, 2015 · 14 comments
Closed

Comments

@scottstensland
Copy link

scottstensland commented Mar 26, 2015

Please update ERROR message when attempting to call

JSON.stringify(monsterously_HUGE_object)

Today when it runs out of RAM above gives this message

RangeError: Invalid string length

when it clearly should indicate the system is out of RAM.
Searching this error message I see nodejs does recognize
an Out Of Memory condition yet it continues to give a less helpful error message

https://github.com/joyent/node/search?utf8=%E2%9C%93&q=RangeError%3A+Invalid+string+length

@Fishrock123
Copy link

That's an issue from v8 (the javascript engine) not node. (JSON.* is implemented in v8)

@misterdjules
Copy link

It would help to know how monsterously_HUGE_object is created, as if it's created in some way that requires allocating too much memory before any string operation can be done, it will fail with an "Out of memory" error.

Otherwise, operating on a string that is too large should throw the "Invalid string length" error, so I don't see anything that would be unexpected.

As @Fishrock123 mentioned, these errors are thrown from V8, so if you still think that these error messages are not correct, I encourage you to file an issue in V8's issues tracker.

Closing for now, but please let us know if you have any question.

@cauerego
Copy link

While I do get it this is the wrong place to ask about this issue, this is also the first hit on google, so...

Any links to where we could look for a solution to the actual problem? I still think I need to stringify a huge object (to enable people to save and share their Mariox's advancements), certainly over 5mb ( I'll lz compress it later, if this matters to you ;P ).

@apple-hacker
Copy link

I have a problem about this,please help me!

@sign0
Copy link

sign0 commented Apr 14, 2016

me too ! 👎 (ubuntu 14.04, nodejs 5.10.1)

@SashaDesigN
Copy link

Have to this problem now with json files) try use on ubuntu:

cat file1.json file2.json > res.json

@jcollum
Copy link

jcollum commented Jun 9, 2016

same here, csv-stringify library but this is the first google hit; I'm csv-ing a record from a very very wide table in SQL

@lianyi
Copy link

lianyi commented Dec 30, 2016

same issue at node v6.2.2 on CentOS 7

@krazyjakee
Copy link

Same here 7.9.0 - Webpack cannot build

@PassTheMayo
Copy link

Same issue here. Ubuntu 16.04, Node v8.1.4

@LKJonDoe
Copy link

LKJonDoe commented Aug 3, 2017

is there any fix ?

@majuss
Copy link

majuss commented Aug 7, 2017

same issue…

@sandeeptharayilGit
Copy link

facing same issue RangeError: Invalid string length

@gibfahn
Copy link
Member

gibfahn commented Aug 19, 2017

This repo is an archive, if you're still seeing this please open an issue at nodejs/node (if there isn't one there already).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests