Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Client returns a call's result before handling notifications that preceded it

オープン
#1,337 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

P3

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 CallTool can 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.

主要言語
Go
スター
5.2k
フォーク
568
平均マージ
1日 15時間
マージ済み PR(30日)
39

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/go-sdk のほかの issue

modelcontextprotocol/go-sdk の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。