Potential race condition in (*mcp.ClientSession).Close()
維護者通常 1 天內回覆
評估
研究方向
先從 gopls/internal/cmd/mcp_test.go 中的 TestMCPCommandLogging 附近以及 gopls/internal/cmd/mcp.go 開始,然後執行 go test -run ^TestMCPCommandLogging$ -count=100 golang.org/x/tools/gopls/internal/cmd 來重現這個間歇性故障。追蹤 MCP 用戶端關閉與子程序終止之間的互動;在重複執行過程中用戶端連線均能無錯誤地關閉,即表示完成。
由索引模型根據 Issue 內容生成。
描述
We've experienced an increasing number of test flakes in the tests for our MCP server. There is an error when closing the connection at the end of the tests: "server is closing: EOF". We think there might be a bug in mcp causing a race between the active part of Close (which breaks the connection and terminates the child process) and the waiting part of close (which seems to observe an error from the terminated child without realizing that close itself was responsible). Alan began tracing the issue here: https://github.com/golang/go/issues/77336#issuecomment-4090756198
To Reproduce
The test is here: https://github.com/golang/tools/blob/36360cdf844bb2553617bdc496c8d972c7229e7d/gopls/internal/cmd/mcp_test.go#L109
Server code is here: https://github.com/golang/tools/blob/master/gopls/internal/cmd/mcp.go
Try to reproduce the failure locally by using -count=100:
go test -run ^TestMCPCommandLogging$ -count=100 golang.org/x/tools/gopls/internal/cmd
=== RUN TestMCPCommandLogging/trace.log
gopls: server is closing: EOF
mcp_test.go:156: closing MCP connection: exit status 2
Expected behavior
Client connection closes without error.
- 主要語言
- Go
- 星號
- 5.4k
- 分支
- 623
- 平均合併
- 22 小時 10 分鐘
- 30 天內合併 PR
- 30
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
modelcontextprotocol/go-sdk 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
modelcontextprotocol/go-sdk#1557 ·
維護者通常 1 天內回覆
-
Streamable HTTP (2026-07-28): tools/call with an out-of-range number in arguments fails because extractName decodes Arguments into any可能重新可做 @beiryu 於 10 天前認領,目前沒有進行中的 PR。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
modelcontextprotocol/go-sdk#1534 · 1 則留言 ·
維護者通常 1 天內回覆
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensions可能重新可做 關聯的 PR 已關閉且未合併。 未關閉needs investigation
難度 2/5 1-3 小時 新手友好度 72/100
modelcontextprotocol/go-sdk#745 · 13 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 18/100
modelcontextprotocol/go-sdk#1555 ·
維護者通常 1 天內回覆
-
mcp: 2026-07-28 client runs elicitation and sampling handlers for standalone server requests可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 3/5 1-2 天 新手友好度 35/100
modelcontextprotocol/go-sdk#1552 ·
維護者通常 1 天內回覆
查看 modelcontextprotocol/go-sdk 的全部 Issue
相似的 Issue
-
難度 1/5 1-3 小時 新手友好度 88/100
-
難度 2/5 1-3 小時 新手友好度 70/100
compiler-explorer/compiler-explorer#9738 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 85/100
evilmartians/lefthook#1674 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆