Protobuf: google-protobuf.js:215 Uncaught RangeError: Maximum call stack size exceeded

Created on 19 May 2016  路  4Comments  路  Source: protocolbuffers/protobuf

When trying to parse a large protobuf message.
The message contains a string field with base64 encoded image.

The issue appears when using the generated classes for javascript.
Classes were generated using protobuf compiler protobuf-js-3.0.0-alpha-6.

bug javascript

Most helpful comment

Thanks for all the info! Since we depend on the Google Closure library, perhaps we should just use the goog.crypt.byteArrayToString() function directly. That seems like the simplest solution.

All 4 comments

We encountered the same issue when trying to pass a very large JSON string in one of the protobuf message fields, resulting in the following error

RangeError: Maximum call stack size exceeded
    at jspb.BinaryDecoder.readString (http://localhost:9000/.protobuf/latest/js/binary/decoder.js:933:36)

and when we dug a little deeper into this it seemed like the problem was being caused by this specific line of code

var result = String.fromCharCode.apply(null, chars)

so we tested this for a smaller string size and everything seemed to work fine, and when we looked around we found that this is a part of a known problem which has been mentioned here on stack-overflow. The same issue has been fixed in the google closure library using a chunking approach which can be adopted here as well. Also this note on the mozilla developer page should help in adding proper tests and a fix for this bug.

Thanks for all the info! Since we depend on the Google Closure library, perhaps we should just use the goog.crypt.byteArrayToString() function directly. That seems like the simplest solution.

Just raised #2873 to fix this and confirmed that the fix in that #2873 resolves the issue referenced by @subash-a above

I am running into this as well, deserialize is failing on large messages in Javascript.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jtattermusch picture jtattermusch  路  83Comments

Interfere picture Interfere  路  30Comments

mitar picture mitar  路  37Comments

larribas picture larribas  路  48Comments

tbillington picture tbillington  路  29Comments