If the client receives a partial message, createFrom will throw an exception which will cause the stream to be cleared after the try catch, which will result in losing the data. More importantly, as we have already read the header bytes from the stream, the position will be non-zero which will cause clear to throw StateError.
If the client receives a partial message, createFrom will throw an exception which will cause the stream to be cleared after the try catch, which will result in losing the data. More importantly, as we have already read the header bytes from the stream, the position will be non-zero which will cause clear to throw StateError.