mcp: close HTTP response body from DELETE request in streamableClientConn.Close#929
Open
blackwell-systems wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
…Conn.Close The DELETE request that terminates the session discards the response without closing its body. This leaks the underlying TCP connection on every normal session close, since the default transport has keep-alives enabled and net/http requires Body.Close for connection reuse. All other client.Do call sites in this file (10 of them) close the response body. This one was missed. Fixes modelcontextprotocol#928
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The DELETE request that terminates a streamable HTTP session discards the
*http.Responsewithout closing its body. Per thenet/httpdocumentation, this prevents the underlying TCP connection from being reused and leaks it.The bug
On the success path (no error), the response is silently discarded. The default client is
http.DefaultClientwith keep-alives enabled, so the leaked connection stays open until GC or process exit.The fix
All 10 other
client.Docall sites in this file close the response body. This one was missed.Test plan
go build ./...passesgo test ./... -shortpassesFixes #928