Skip to content

Fix stray compressed bytes before PROCEED on large messages - #730

Merged
rhysparry merged 1 commit into
mainfrom
rhys/lev-2142/fix-stray-compressed-bytes
Oct 23, 2026
Merged

rhysparry merged 1 commit into
mainfrom
rhys/lev-2142/fix-stray-compressed-bytes

Conversation

@rhysparry

@rhysparry rhysparry commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Background

UsageFixture.LargeMessages sometimes fails on Windows/net48 because a stray byte appears in front of a control message, for example Expected PROCEED, got: \u001fPROCEED (LEV-2142, LEV-2098).

The stray byte is left over from the previous message. For large messages, Halibut stops reading the compressed stream as soon as the message is complete. But the compressed stream can end with a byte or two that the message doesn't need. If those bytes arrive late, Halibut never reads them, and they're read as part of whatever comes next.

This is a bug in Halibut, not in .NET Framework. It affects all frameworks and older Halibut versions too, but it's rare. It only happens when those last bytes arrive in a separate network read. net48 likely hits it more often because of how its zlib splits its output, but we haven't confirmed that.

Results

After reading a message, Halibut now keeps reading the compressed stream until it reports the end. That consumes any remaining bytes before the next message is read.

If the compressed stream has more data after the message, Halibut now throws a ProtocolException instead of ignoring it. Halibut never sends data like that.

A new test reproduces the problem by delivering the last compressed bytes in a separate read.

Before

The new test fails, and the data after the message starts with a stray byte:

"\u0000PROCEED"

After

The new test passes, and the data after the message is PROCEED.

How to review this PR

Quality ✔️

  • The fix is in MessageSerializer.ReadCompressedMessageAsync.
  • The new test hasn't run on net48 yet, so keep an eye on the Windows/net48 build.
  • This only fixes readers running this version. Older readers, such as the 5.0.236 service in LEV-2142, can still hit it, so those compatibility tests may still fail occasionally.

Pre-requisites

  • I have read How we use GitHub Issues for help deciding when and where it's appropriate to make an issue.
  • I have considered informing or consulting the right people, according to the ownership map.
  • I have considered appropriate testing for my change.

🤖 Generated with Claude Code

🤖 Agent's description, endorsed by Rhys

@rhysparry
rhysparry marked this pull request as ready for review October 23, 2026 01:36
@rhysparry
rhysparry requested a review from a team as a code owner October 23, 2026 01:36
@rhysparry
rhysparry merged commit cf9f4dd into main Oct 23, 2026
13 checks passed
@rhysparry
rhysparry deleted the rhys/lev-2142/fix-stray-compressed-bytes branch October 23, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants