Repository navigation
Conversation
Signed-off-by: bbdu3 <ergouyang854@gamil.com>
Signed-off-by: bbdu3 <ergouyang854@gamil.com>
1AbdullahButt
left a comment
There was a problem hiding this comment.
I read this against Heartbeat.isHeartbeat and Heartbeat.from, and the loop is correct for every split:
isHeartbeatusesprefix(4)on the buffer, so it works on theDataslices thatdropFirstand the newline split produce (no index-0 assumptions).- With 1–3 bytes of the magic header buffered,
isHeartbeatis false, the newline search finds nothing and the loop breaks to wait for more data. With 4–11 bytes, thecount >= 12guard waits as well. The0...13cases cover both. - Consuming a fixed 12 bytes for the heartbeat also fixes a quieter problem: the old code could split on a
0x0Abyte inside the 8-byte timestamp if a heartbeat ever landed in the buffer.
The marker message in the test is a nice touch: the test still ends on the old code instead of hanging.
Reviewed with help from Claude Code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NetworkTransportpreviously skipped an entire receive chunk when it began with a heartbeat, discarding any following JSON-RPC messages. Parse buffered frames so the heartbeat is consumed without losing subsequent messages.Fixes #322.
Changed
Test
git diff --checkpassed.