Client returns a call's result before handling notifications that preceded it
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- go
- Área
- backend-api-design
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Go
- Estrellas
- 5.2k
- Forks
- 568
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 36
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de modelcontextprotocol/go-sdk
-
Session-lifecycle bookkeeping logs at info, spamming multiple log lines per request on stateless streamable HTTPPosiblemente ocupada @anneheartrecord la tomó hace 41 días. AbiertoP3
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
modelcontextprotocol/go-sdk#1204 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensionsPosiblemente ocupada @ajuijas la tomó hace 207 días. Abiertoneeds investigation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
modelcontextprotocol/go-sdk#745 · 13 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
auth: Authorize fails against a 2025-03-26 server whose URL has a query stringPosiblemente ocupada @akshita317 la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 40/100
modelcontextprotocol/go-sdk#1347 ·
Los mantenedores suelen responder en 1 día
-
mcp: Client.Connect never falls back to initialize when a stdio server ignores server/discoverPosiblemente ocupada @crossxr la tomó hace 6 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
modelcontextprotocol/go-sdk#1332 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
modelcontextprotocol/go-sdk#1331 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de modelcontextprotocol/go-sdk
Issues similares
-
Broken Claude manifestAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
[Chore] Remove dead AutogenV2 feature flagPosiblemente ocupada @geeknishantkyeus la tomó hoy. Abiertobug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
kyverno/kyverno#17936 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
enhancement model:sonnet phase-2-optimize runtime:claude security size:S
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
FootprintAI/Containarium#2416 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día