Add regression test for stateless request memory cleanup #1140
+64
−1
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
This PR adds a regression test for the memory leak fix from PR #1116. The test ensures that transport resources are properly cleaned up after handling stateless requests in the StreamableHTTPSessionManager.
Problem
PR #1116 identified a memory leak where transport instances were not being terminated after handling stateless requests. This could lead to resource accumulation over time as streams and other resources were not properly closed.
Solution
The test verifies that:
terminate()
method is called after each stateless request_terminated
flag and_request_streams
) is properly cleaned upTest Implementation
The test creates real StreamableHTTPServerTransport instances and verifies the cleanup behavior rather than relying on mocks. This provides a more robust test that validates the actual behavior of the system.
Related to #1116