You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So what happens is that if you have a stream (a pipe used for IPC in my case) and the other side sends an large chunk of data, the recipient throws an exception before any application code is invoked that could handle it gracefully.
Additional information
I don't know exactly how large the buffer has to be. In my application (electron 8.5.2 with node 12.13.0) this started happening at around 600MB, when reproducing in node on the command line I had to increase the buffer to 1GB.
Just to clarify: I understand that there will be a limit on how large these buffers can get, I just wish it would report an error that my application code can handle because right now I don't see how I could write robust client code that can deal with the other side sending crap.
The size limit is exactly 0x1fffffe8 (536870888) characters. That's the maximum length a JS string can have in the V8 engine. The method correctly throws an error if the decoder is setup with ascii encoding. I'm looking into why that doesn't happen with utf-8
Activity
targos commentedon Dec 28, 2020
The size limit is exactly 0x1fffffe8 (536870888) characters. That's the maximum length a JS string can have in the V8 engine. The method correctly throws an error if the decoder is setup with
asciiencoding. I'm looking into why that doesn't happen withutf-8targos commentedon Dec 28, 2020
Well, I don't know why there's no exception propagating to JS...
Relevant lines in the code:
node/src/string_decoder.cc
Lines 265 to 268 in d146b25
node/src/string_decoder.cc
Lines 208 to 211 in d146b25
node/src/string_decoder.cc
Lines 32 to 38 in d146b25
/cc @addaleax
targos commentedon Dec 28, 2020
It's like
String::NewFromUtf8returns an emptyMaybeLocal<String>but without a pending exception.addaleax commentedon Dec 28, 2020
Yeah, it does – that’s a long-standing TODO in the V8 source… we should probably throw one ourselves :/
targos commentedon Dec 28, 2020
I see... Working on it!
string_decoder: throw ERR_STRING_TOO_LONG for UTF-8
targos commentedon Dec 28, 2020
PR at #36661
string_decoder: throw ERR_STRING_TOO_LONG for UTF-8
string_decoder: throw ERR_STRING_TOO_LONG for UTF-8
string_decoder: throw ERR_STRING_TOO_LONG for UTF-8
string_decoder: throw ERR_STRING_TOO_LONG for UTF-8
string_decoder: throw ERR_STRING_TOO_LONG for UTF-8