You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NetworkTransport drops a JSON message when a TCP receive contains a heartbeat followed by the message #322
NetworkTransport.receiveLoop() skips an entire received data chunk when Heartbeat.isHeartbeat(newData) returns true. This check only examines the first four bytes, so a chunk containing a heartbeat followed by a JSON-RPC message is treated entirely as a heartbeat.
How to trigger
The sender writes a 12-byte heartbeat, followed by a newline-delimited JSON-RPC message. TCP can deliver these two writes together in one receive callback:
The receiver recognizes the heartbeat prefix and executes continue before reaching buffer.append(newData). The JSON-RPC message following the heartbeat is therefore discarded.
I validated this using a Python model of the relevant receive-loop logic, with a second response as a marker:
Separate chunks: heartbeat, response 1, response 2
Delivered response IDs: [1, 2]
Combined chunk: heartbeat + response 1, followed by response 2
Delivered response IDs: [2]
I also tested two separate writes over Linux TCP loopback. In 20 trials, the heartbeat and first response arrived together in one recv() call, with all bytes intact.
These checks establish that the input arrangement can occur over TCP and that the modeled receive logic drops the trailing message. I have not run the Swift SDK or Network.framework on macOS.
Impact
A JSON-RPC message following a heartbeat in the same receive chunk is not delivered through the transport’s receive stream. If it is a response, its pending request can remain unresolved until cancellation, disconnection, or an application-level timeout.
This report is limited to TCP and the case of a complete heartbeat followed by a complete JSON-RPC message in one receive callback.
my fix thought
The receiver should parse frames from buffered bytes instead of treating each receive callback as a complete application message. After identifying a complete heartbeat, it should consume only those 12 bytes and continue processing any remaining bytes.
A regression test could queue heartbeat + response 1 as one chunk, then response 2 as another, and assert that both responses are delivered in order. The same assertion should pass when the heartbeat and responses arrive separately.
If my repair strategy is right, I will open a PR to fix it.
Fixed on rel/1.0.0 (#372) in #400 and #413: NetworkTransport no longer sends heartbeats, and incoming heartbeat frames from 0.12 peers are skipped only at message boundaries in the receive buffer without dropping any JSON-RPC messages coalesced in the same TCP read. Closing as resolved in 1.0.0.
Activity
jeanmatthieu commentedon Dec 5, 2026
Fixed on
rel/1.0.0(#372) in #400 and #413:NetworkTransportno longer sends heartbeats, and incoming heartbeat frames from 0.12 peers are skipped only at message boundaries in the receive buffer without dropping any JSON-RPC messages coalesced in the same TCP read. Closing as resolved in 1.0.0.