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.
|
Hi @bbdu3, thank you for identifying the coalesced-heartbeat message loss bug (#322) and contributing this fix and regression cases! This is resolved on Could you please close this PR if |
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.