Currently there is a bug depending on how chunks are split because if the requested bits consume all the available bits, bytes has no value.
By moving the buffer request, the code requests a buffer only when it needs it, lowering the potential of a bug.
This does not fix all the Cannot read property '0' of undefined problems (I am still looking into it) but fixes one case I found when using { highWaterMark: 1} in long.js
Currently there is a bug depending on how chunks are split because if the requested bits consume all the available bits, bytes has no value.
By moving the buffer request, the code requests a buffer only when it needs it, lowering the potential of a bug.
This does not fix all the Cannot read property '0' of undefined problems (I am still looking into it) but fixes one case I found when using { highWaterMark: 1} in long.js