Fix leaked anyio streams in streamable_http#1991
Open
aabmass wants to merge 7 commits intomodelcontextprotocol:mainfrom
Open
Fix leaked anyio streams in streamable_http#1991aabmass wants to merge 7 commits intomodelcontextprotocol:mainfrom
aabmass wants to merge 7 commits intomodelcontextprotocol:mainfrom
Conversation
aad9e69 to
aff1b13
Compare
aff1b13 to
42891f4
Compare
42891f4 to
de5d624
Compare
Kludex
reviewed
Feb 5, 2026
Comment on lines
+624
to
+625
| finally: | ||
| await sse_stream_reader.aclose() |
Member
There was a problem hiding this comment.
Why does the reader moves to the finally but not the writer?
Author
There was a problem hiding this comment.
On L569 it gets stored
# Store writer reference so close_sse_stream() can close it
self._sse_stream_writers[request_id] = sse_stream_writerShould I be closing it here too, or does it need to outlive this function?
Kludex
reviewed
Feb 5, 2026
| except Exception: | ||
| except Exception: # pragma: lax no cover | ||
| logger.exception("Error in standalone SSE response") | ||
| await self._clean_up_memory_streams(GET_STREAM_KEY) |
Author
There was a problem hiding this comment.
This stays in the except block same as before. Should this happen in finally regardless of exception?
Kludex
reviewed
Feb 5, 2026
acf0bbf to
b11e04f
Compare
…elcontextprotocol#1961) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.
Motivation and Context
Fixes a resource leak. I was seeing this in tests I am writing for a different issue (#421 (comment)). Before:
How Has This Been Tested?
Added a new test as first commit in this PR which fails. It passes with the fix, and I was able to remove a bunch of
pragma: no coverstatements.Breaking Changes
No
Types of changes
Checklist
Additional context