Client returns a call's result before handling notifications that preceded it
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Start in internal/jsonrpc2/conn.go, tracing readIncoming, acceptRequest, handlerQueue, and handleAsync to compare response retirement with queued notification handling. Run go test -count=1 -v ./... in the reproduction repository and inspect order_test.go and wire_test.go. Done means notifications received before a response are handled before CallTool returns, or a documented wait mechanism is covered by passing tests.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When a server sends notifications during a request and then its response, the go-sdk client can return from CallTool before it has run the handlers for those notifications. Over in-memory transports the wire order is correct and the client reorders delivery; over Streamable HTTP the symptom is the same, but the wire order was not measured.
In internal/jsonrpc2/conn.go, readIncoming retires a *Response immediately, which wakes the Call waiting on it, while an incoming *Request (a notification included) goes through acceptRequest onto handlerQueue and is handled later by handleAsync on another goroutine. Notifications read before a response can therefore be handled after CallTool has returned.
For a plain client this means a ProgressNotificationHandler may still be running for a call that has already returned. LoggingMessageHandler should be affected the same way, since log messages take the same path through jsonrpc2.Connection, but the tests measure progress only.
For anything built on both halves of the SDK -- a gateway or proxy that forwards an upstream's progress to its own caller (the client calling the proxy) -- there is no correct way to forward. The proxy has to stop forwarding a call's progress at some point, and the only moment the SDK gives it is the upstream CallTool returning, when progress the upstream sent before its response may not have been handled yet. If it stops there, that progress is lost. If it keeps forwarding, the progress reaches its caller after the proxy has answered, which 2025-11-25 basic/utilities/progress forbids: "Progress notifications MUST only reference tokens that ... were provided in an active request", and "Progress notifications MUST stop after completion."
Nothing in the API says how many notifications preceded a response, or when they have been handled, so neither a client nor a proxy can wait for them.
To Reproduce
Four tests, each asserting the property that should hold, so a failing run is the reproduction: https://github.com/serverplumber/go-sdk-notify-order/tree/6230dcf2db9d0588ac9252a04d420f4c5f83db3a (order_test.go, wire_test.go; RESULTS.md has the per-run counts). Run go test -count=1 -v ./....
A tool reports progress three times and returns at once. No handler sleeps. The test clients' handlers only count, under a mutex; the proxy's forwards each notification, which is what a proxy is for. Three runs of 1000 calls each, at v1.8.0 and at main (25a53e3), Go 1.26.7 on linux/amd64:
| Test | v1.8.0 | main |
|---|---|---|
In-memory transports: calls whose CallTool returned before all 3 progress handlers ran |
69–80 | 43–58 |
| Streamable HTTP: the same | 342–373 | 374–399 |
| Proxy that stops forwarding when the upstream call returns: progress lost, of 3000 | 472–488 | 460–472 |
| Proxy that keeps forwarding: progress its caller read after the response, of 3000 | 579–591 | 575–608 |
The in-memory test also records the order the client's transport delivers messages in: every call's progress arrives before its response, in every run, so the reordering happens after Read, in jsonrpc2.Connection. The last proxy figure is counted at the transport of the proxy's caller for the same reason -- it is what the proxy sent, not the caller's own reordering.
Expected behavior
Handlers for notifications received before a response have run by the time the call that response settles returns -- or, failing that, the client offers a way to wait for them. Either lets a proxy forward progress before its own response.
Possible directions (for discussion, not a patch)
- Deliver a response through the same ordered path as incoming notifications, so retiring it waits for the handlers queued ahead of it.
- Or expose a barrier: something the code that called
CallToolcan wait on that completes when everything read before the response has been handled.
Additional context
Found building an MCP gateway on go-sdk for fault-injection testing. The gateway works around it by counting notifications/progress for a call's token on the HTTP event stream ahead of the response, and waiting until that many are forwarded -- which needs an http.RoundTripper that parses SSE, because the SDK gives no other handle on it. Before the workaround, the gateway's own test saw 1 of 3 progress notifications downstream: the other two were handled after the upstream call returned, by which time the gateway had answered and stopped forwarding for that call.
- Ngôn ngữ chính
- Go
- Star
- 5.2k
- Fork
- 568
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 39
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- 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/go-sdk
-
Session-lifecycle bookkeeping logs at info, spamming multiple log lines per request on stateless streamable HTTPCó thể đã có người làm @anneheartrecord đã nhận 42 ngày trước. Đang mởP3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelcontextprotocol/go-sdk#1204 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensionsCó thể đã có người làm @ajuijas đã nhận 208 ngày trước. Đang mởneeds investigation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/go-sdk#745 · 13 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mcp: client returns an input_required result that has only requestState instead of retryingCó thể đã có người làm @SergeevDmitry đã nhận hôm nay. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 62/100
modelcontextprotocol/go-sdk#1364 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
modelcontextprotocol/go-sdk#1359 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Streamable HTTP: a tool result that fails to marshal leaves the POST hanging (no JSON-RPC error)Đang mở
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 45/100
modelcontextprotocol/go-sdk#1358 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/go-sdk
Issue tương tự
-
Discriminator mapping keys are listed in a random orderCó thể đã có người làm @reuvenharrison đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 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
-
Idle compaction monitors LIST the replica every tick when the newest destination file spans more than one TXIDCó thể đã có người làm @pishuv đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
benbjohnson/litestream#1563 ·
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 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-research agent-review-finding chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
jordansmall/spindrift#4922 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
gcsartifact: deleting a missing version returns an errorCó thể đã có người làm @ktsoator đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày