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

RangeError: Invalid string length #335

Open
hogggy opened this issue Jun 21, 2017 · 7 comments
Open

RangeError: Invalid string length #335

hogggy opened this issue Jun 21, 2017 · 7 comments

Comments

@hogggy
Copy link

hogggy commented Jun 21, 2017

We are getting this error RangeError: Invalid string length. This happens almost every time an error is reported and attempted to be sent to sentry. Here is the stack trace:

RangeError: Invalid string length
  ?, in join
  ?, in Object.stringify
  File "/app/node_modules/json-stringify-safe/stringify.js", line 5, col 15, in stringify
    return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces)
  File "/app/node_modules/raven/lib/client.js", line 289, col 19, in Raven.send
    var skwargs = stringify(kwargs);
  File "/app/node_modules/raven/lib/client.js", line 276, col 12, in Raven.process
    this.send(kwargs, cb);
  File "/app/node_modules/raven/lib/client.js", line 336, col 12, in null.<anonymous> self.process(eventId, kw, cb);
  File "/app/node_modules/raven/lib/parsers.js", line 52, col 5, in null.<anonymous> 
   cb(kwargs);
  File "/app/node_modules/raven/lib/utils.js", line 214, col 5, in null.<anonymous> 
    cb(frames);
  File "/app/node_modules/raven/lib/utils.js", line 153, col 35, in null.<anonymous>
    if (--numFilesToRead === 0) cb(sourceFiles);
  File "fs.js", line 446, col 3, in FSReqWrap.readFileAfterClose [as oncomplete]

Here is my sentry config.

{
    maxBreadcrumbs: 10,
    environment: process.env.NODE_ENV,
    autoBreadcrumbs: {
        'console': false,
        'http': true,
    }
}

I think this is an out of memory issue in the stringify function. This is preventing the correct error from being sent to sentry.

@MaxBittker
Copy link
Contributor

MaxBittker commented Jun 21, 2017

hi @hogggy thanks for opening the issue. what version of raven are you on? investigating this now

@MaxBittker
Copy link
Contributor

the problem is that too much data is being attached to an event - are you using any of the Raven context methods or adding custom breadcrumbs? something very large is ending up on the object

@hogggy
Copy link
Author

hogggy commented Jun 21, 2017

hi @MaxBittker
I am using raven version 2.02.
I am not using any raven context methods or custom breadcrumbs or any other unique raven configuration.
I understand that's what's happening I'm just not sure why. I will see if i can find out more about what's happening.

@MaxBittker
Copy link
Contributor

are you using minified code?

a few things to try: upgrading to 2.1.0 to take advantage of #329

editing your node_modules a putting a console.log(kwargs) before

  File "/app/node_modules/raven/lib/client.js", line 289, col 19, in Raven.send
    var skwargs = stringify(kwargs);

@adrien-f
Copy link

adrien-f commented Jul 3, 2017

Hello,

I've updated to raven@2.1.0 and we've been hit by this issue as well.

We have a 1.8MB file compiled by Webpack and when issues occur inside it, we're either hit with a Javascript heap out of memory or RangeError: Invalid string length. from JSON.stringify (native). The stacktrace itself is quite huge since it's pretty deep. I've been trying to play with v8 flags to reduce this stacktrace but with no success.

Let me know if you need more info,

Error: some error
    at someReduxSaga$ (C:\Users\projectHome\node_modules\@mycompany\companyproject\build\server.js:18357:17)
    at tryCatch (C:\Users\projectHome\node_modules\regenerator-runtime\runtime.js:65:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\projectHome\node_modules\regenerator-runtime\runtime.js:303:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\projectHome\node_modules\regenerator-runtime\runtime.js:117:21)
    at next (C:\Users\projectHome\node_modules\redux-saga\lib\internal\proc.js:313:27)
    at proc (C:\Users\projectHome\node_modules\redux-saga\lib\internal\proc.js:272:3)
    at runForkEffect (C:\Users\projectHome\node_modules\redux-saga\lib\internal\proc.js:557:19)
    at runEffect (C:\Users\projectHome\node_modules\redux-saga\lib\internal\proc.js:436:546)
    at next (C:\Users\projectHome\node_modules\redux-saga\lib\internal\proc.js:317:9)
    at currCb (C:\Users\projectHome\node_modules\redux-saga\lib\internal\proc.js:389:7)
    at takeCb (C:\Users\projectHome\node_modules\redux-saga\lib\internal\proc.js:468:108)
    at Object.put (C:\Users\projectHome\node_modules\redux-saga\lib\internal\channel.js:85:16)
    at C:\Users\projectHome\node_modules\redux-saga\lib\internal\channel.js:173:10
    at C:\Users\projectHome\node_modules\redux-saga\lib\internal\channel.js:198:16
    at exec (C:\Users\projectHome\node_modules\redux-saga\lib\internal\scheduler.js:25:5)
    at flush (C:\Users\projectHome\node_modules\redux-saga\lib\internal\scheduler.js:66:5)
    at asap (C:\Users\projectHome\node_modules\redux-saga\lib\internal\scheduler.js:39:5)
    at Array.<anonymous> (C:\Users\projectHome\node_modules\redux-saga\lib\internal\channel.js:197:27)
[SNIP]
    at trim_prefix (C:\Users\projectHome\node_modules\express\lib\router\index.js:317:13)
    at C:\Users\projectHome\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (C:\Users\projectHome\node_modules\express\lib\router\index.js:335:12)
    at next (C:\Users\projectHome\node_modules\express\lib\router\index.js:275:10)
    at Function.handle (C:\Users\projectHome\node_modules\express\lib\router\index.js:174:3)
    at EventEmitter.handle (C:\Users\projectHome\node_modules\express\lib\application.js:174:10)
    at Server.app (C:\Users\projectHome\node_modules\express\lib\express.js:38:9)
    at emitTwo (events.js:106:13)
    at Server.emit (events.js:191:7)
    at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:546:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)

@timewarrior
Copy link

We are facing this issue too. We are on 2.1.0
This is our config

Raven.config(config.sentryBackendUrl, {
    release: appVars.gitCommitID,
    environment: config.environment
  }).install();
RangeError: Invalid string length
    at join (native)
    at Object.stringify (native)
    at stringify (/var/app/current/node_modules/raven/node_modules/json-stringify-safe/stringify.js:5:15)
    at Raven.send (/var/app/current/node_modules/raven/lib/client.js:269:19)
    at Raven.process (/var/app/current/node_modules/raven/lib/client.js:256:12)
    at /var/app/current/node_modules/raven/lib/client.js:316:12
    at /var/app/current/node_modules/raven/lib/parsers.js:52:5
    at /var/app/current/node_modules/raven/lib/utils.js:245:5
    at /var/app/current/node_modules/raven/lib/utils.js:160:35
    at wrappedCallback (/var/app/current/node_modules/newrelic/lib/transaction/tracer/index.js:326:17)
    at wrapped (/var/app/current/node_modules/newrelic/lib/transaction/tracer/index.js:184:28)
    at wrappedCallback (/var/app/current/node_modules/newrelic/lib/transaction/tracer/index.js:452:66)
    at wrapped (/var/app/current/node_modules/newrelic/lib/transaction/tracer/index.js:184:28)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

@MaxBittker
Copy link
Contributor

MaxBittker commented Oct 3, 2017

hmmm.. us failing gracefully here and adding more debug output is all I can think of for the time-being, is there anything either of you could do to help us reproduce this?

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

No branches or pull requests

5 participants