From 885c1b09e527a9204db509283d5027370e238d99 Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Thu, 1 Feb 2018 11:38:57 -0800 Subject: [PATCH] Do not choke on MessageSet without version If we end un unlucky and MessageSet buffer is truncated right before we can read magic value, we just return `ErrInsufficientData`, even if some messages were previously successfully parsed. This propagates all the way up to `partitionConsumer`, where we zero parsed messages, which results in `ErrMessageTooLarge` returned to the consumer. This commit fixes the issue by setting `PartialTrailingMessage` to `true` on `MessageSet`, making it possible to read successfully parsed messages. --- message_set.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/message_set.go b/message_set.go index 3895ab6a5..27db52fdf 100644 --- a/message_set.go +++ b/message_set.go @@ -66,6 +66,10 @@ func (ms *MessageSet) decode(pd packetDecoder) (err error) { for pd.remaining() > 0 { magic, err := magicValue(pd) if err != nil { + if err == ErrInsufficientData { + ms.PartialTrailingMessage = true + return nil + } return err }