NetworkTransport drops a JSON message when a TCP receive contains a heartbeat followed by the message
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- swift
- Lĩnh vực
- networking
Hướng nghiên cứu
Read NetworkTransport.receiveLoop() and the heartbeat framing logic to see how received bytes are buffered and consumed. Then inspect the transport tests for a way to deliver multiple frames in one chunk; done means a heartbeat followed by a JSON-RPC response and a later response are both delivered in order. A linked open pull request is already addressing this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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:
[heartbeat][{"jsonrpc":"2.0","id":1,"result":{}}\n]
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.
- Ngôn ngữ chính
- Swift
- Star
- 1.6k
- Fork
- 270
- Merge trung bình
- 2 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/swift-sdk
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
modelcontextprotocol/swift-sdk#327 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Value decoding changes data-URL-looking JSON strings into Value.dataCó thể đã có người làm @bitbemol đã nhận 73 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
modelcontextprotocol/swift-sdk#277 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/swift-sdk#274 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`HTTPClientTransport` fails to build on Windows: `#if !os(Linux)` guards no longer match the `EventSource` platform conditionCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
modelcontextprotocol/swift-sdk#261 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Client.withBatch leaves per-request tasks pending when transport.send throwsCó thể đã có người làm @bbdu3 đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
modelcontextprotocol/swift-sdk#324 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của modelcontextprotocol/swift-sdk
Issue tương tự
-
[java] TestClassWithoutTestCases: document that abstract classes and interfaces are not checkedĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
文件夹设置bugĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
joeseesun/qiaomu-jot#14 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
30-minutes algorithm any-language beginner-friendly c community cpp csharp data-structures go good first issue hacktoberfest help wanted kotlin learning leetcode php ruby rust swift
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 85/100
Huerte/algo-solutions-python#211 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: build-and-ci S3: minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
manaflow-ai/cmux#39902 ·
Maintainer thường phản hồi trong vòng 1 ngày