mcp: a canceled write on IOTransport/StdioTransport cannot leave the write queue
I maintainer di solito rispondono entro 1 giorno
@Tangerg ci sta già lavorando.
Dal 5/11/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Checklist
- I searched the existing issues, and this has not been reported before.
- This is a real problem that I ran into myself, using the latest release of the SDK.
- I ran into it in a production system, not in a toy example, a benchmark, or an automated or AI-driven scan of the code.
- I (a human) examined the relevant SDK code, and wrote or reviewed every line of this report. It is not unreviewed AI output.
- This report is brief and concise, and sticks to the facts needed to understand the problem.
What happened?
ioConn.Write checks the context only before taking its write mutex. If a write is blocked because the peer stopped reading, another Write whose context is canceled keeps waiting for the mutex instead of returning, and the blocked write itself cannot be interrupted by canceling its context. Callers that bound a request or notification with a deadline therefore hang until the peer reads again.
Expected: a write that has not started returns ctx.Err() without sending anything, and canceling the write in progress stops it (closing the connection, since a partial frame cannot be withdrawn).
AI assistance: the investigation was done with Claude; I reviewed the report and the SDK code.
How to reproduce
package main
import (
"context"
"fmt"
"net"
"time"
"github.com/modelcontextprotocol/go-sdk/jsonrpc"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
func main() {
local, peer := net.Pipe() // the peer never reads, as with a stalled server
defer peer.Close()
conn, err := (&mcp.IOTransport{Reader: local, Writer: local}).Connect(context.Background())
if err != nil {
panic(err)
}
write := func(name string, timeout time.Duration) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
done := make(chan error, 1)
go func() { done <- conn.Write(ctx, &jsonrpc.Request{Method: name}) }()
select {
case err := <-done:
fmt.Printf("%s: returned %v\n", name, err)
case <-time.After(timeout + 2*time.Second):
fmt.Printf("%s: still blocked 2s after its %v deadline\n", name, timeout)
}
}
go write("active", 200*time.Millisecond)
time.Sleep(50 * time.Millisecond)
write("queued", 100*time.Millisecond)
time.Sleep(time.Second)
}
Output with v1.8.0:
queued: still blocked 2s after its 100ms deadline
active: still blocked 2s after its 200ms deadline
Where did you hit this?
Frame hosts MCP plugin processes over stdio; when a plugin stopped reading, shutdown hung on pending writes, so Frame had to wrap SDK writes in its own cancelable layer.
Go MCP SDK version
v1.8.0 (also on main at f91620f)
Go version
go version go1.27.3 darwin/arm64
Logs
No response
- Lingua principale
- Go
- Stelle
- 5.3k
- Fork
- 607
- Merge medio
- 1g 11h
- PR unite (30g)
- 82
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/go-sdk
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensionsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaneeds investigation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
modelcontextprotocol/go-sdk#745 · 13 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
mcp: whether MaxLineLength rejects a message depends on how the stream is readForse già presa @Tangerg l’ha presa oggi. Aperta
modelcontextprotocol/go-sdk#1509 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
modelcontextprotocol/go-sdk#1506 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
mcp: closing a session right after a cancelled call drops notifications/cancelled, so the server handler keeps runningForse già presa @vshalpnjabi l’ha presa oggi. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
modelcontextprotocol/go-sdk#1505 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
mcp: list_changed can only be broadcast; a server cannot notify one session (2026-07-28 subscriptions/listen)Forse già presa @huynle-dev l’ha presa 4 giorni fa. Aperta
Difficoltà 4/5 1-2 giorni Idoneità per principianti 32/100
modelcontextprotocol/go-sdk#1480 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di modelcontextprotocol/go-sdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
adrianbrad/queue#92 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
agent-ready area:skills
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
jmbarzee/temporal-architect#444 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement needs:sonnet ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno