tendermint / js-abci

Javascript ABCI libraries
87 stars 41 forks source link

Update connection.js #35

Open aleksraiden opened 5 years ago

aleksraiden commented 5 years ago

Fix Varint decode failing, if buffer empty (1 byte length). Minimal valid command length = 3

mappum commented 5 years ago

Hey @aleksraiden, thanks for the PR.

I'd like to see a test case for this. And can you elaborate more on the rationale? It seems to me that if the client or server is sending empty buffers with a 1-byte varint, we should still be consuming them from the stream instead of waiting to do it with more data.

aleksraiden commented 5 years ago

As i see, this is "geithenbug". If i connect and read blocks, randomly, i have exception and abci app stop and exit. Yes, any byte at buffer must be checked for valid command, but in this case ve have rangeexception inside the protobuf decoder and then error was propagated to error handler and connection closed. Maybe other solution - return on maybeReadNextMessage if buffer has length == 1, before any varint.decode (today this is first line at fn).