Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError: Invalid string length at onChunkRead #1685

Closed
mourawaldson opened this issue Feb 10, 2017 · 5 comments
Closed

RangeError: Invalid string length at onChunkRead #1685

mourawaldson opened this issue Feb 10, 2017 · 5 comments

Comments

@mourawaldson
Copy link

Lighthouse Version: 1.5.0
Chrome Version: 56.0.2924.87
URL: https://app.ft.com/index_page/home
Error Message: scripts/popup.js:153 RangeError: Invalid string length at onChunkRead (lighthouse-background.js:9579)
background.runLighthouseInExtension.catch.err @ scripts/popup.js:153
Log:

lighthouse-background.js:36680 status Disconnecting from browser... +6s
scripts/popup.js:153 RangeError: Invalid string length
    at onChunkRead (lighthouse-background.js:9579)
background.runLighthouseInExtension.catch.err @ scripts/popup.js:153
lighthouse-background.js:36680 <= Network.requestWillBeSent +6ms Object {documentURL: "https://app.ft.com/index_page/home", frameId: "18752.18", initiator: Object, loaderId: "18752.23", request: Object…}

Note: Since the log is too big I've only added the final lines, let me know if the full log is needed. Also, this was taken from the console log since the app just stopped running without raising any issue to the client level (which in my opinion should be done if any error occur).

@brendankenny
Copy link
Member

brendankenny commented Feb 11, 2017

This is interesting. Happening from the trace being streamed back over the protocol.

I'm not able to reproduce, but the Lighthouse pass is timing out for me before the page has finished loading, so the trace will be fairly large. Maybe it's some kind OOM issue?

@paulirish
Copy link
Member

paulirish commented Feb 11, 2017

Okay fun one. @caseq and I looked into this.

I'm pretty sure it's coming from result += response.data; in onChunkRead.

It's coming from V8 when a string gets to be too big.
What is the max size of a string in V8?
Glad you asked. The answer is 2^28 bytes.. which is 256 megs.


Now you may think, maybe we should build this string in a fashion more efficient than +=? Good idea, bucko, and while that may decrease the memory usage, it won't end up with a smaller string length and we'll still hit this bug.

So, if we want to handle a trace this big, we will need to parse it incrementally. Basically a streaming JSON parser.

DevTools already has code to do that and we've already loaded all those modules so it shouldn't be too hard. :)

see WebInspector.TimelineLoader and WebInspector.TextUtils.BalancedJSONTokenizer.

@mourawaldson
Copy link
Author

@paulirish and @brendankenny,

When trying to reproduce now I get this:

status Evaluating: Estimated Input Latency +18s
lighthouse-background.js:13432 Invalid ProtoExpectation: ignored(6900 6900 undefined) File a bug with this trace!
createInteractionRecord @ lighthouse-background.js:13432
(anonymous) @ lighthouse-background.js:13412
findInputExpectations @ lighthouse-background.js:13412
findUserExpectations @ lighthouse-background.js:13436
buildUserModel @ lighthouse-background.js:13436
buildUserModel @ lighthouse-background.js:13424
run @ lighthouse-background.js:13342
Task.RunSynchronously @ lighthouse-background.js:13342
importTraces @ lighthouse-background.js:13424
init @ lighthouse-background.js:11942
compute_ @ lighthouse-background.js:4704
Promise.resolve.then._ @ lighthouse-background.js:4201

Then after few seconds the extension crashes.

@brendankenny they way I do is basically this:

  1. Open the URL reported.
  2. In another tab go to chrome://extensions then click on "background page (Inactive)" link from Lighthouse (Developer Tools window will open up).
  3. Go back to the tab from step 1. then "Generate report" on the extension.

At this point you should see the trace on "Developer Tools" window.

@paulirish
Copy link
Member

@mourawaldson gotcha. that's a separate bug, though im surprised that actually throws. thanks for reporting it regardless..

@brendankenny
Copy link
Member

fixed by #2593, github just didn't pick up the auto-close

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

No branches or pull requests

3 participants