Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: modelcontextprotocol/python-sdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: brian316/python-sdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Dec 5, 2025

  1. fix(server): Remove redundant transport termination to prevent race c…

    …ondition
    
    Resolves a race condition in the `StreamableHTTPSessionManager` that caused an `anyio.ClosedResourceError` when handling requests in stateless mode.
    
    The `_handle_stateless_request` function was explicitly calling `await http_transport.terminate()` after processing a request. This created a race condition where the transport's streams could be closed while still being used by the background `message_router` task, leading to a crash.
    
    The lifecycle of the transport's streams is already correctly managed by the `async with http_transport.connect()` context manager, which ensures that all resources are safely cleaned up in its `finally` block when the background task completes.
    
    This commit removes the redundant and problematic `terminate()` call, allowing the context manager to handle resource cleanup as intended. This fixes the race condition and improves the stability of stateless request handling.
    brian316 authored Dec 5, 2025
    Configuration menu
    Copy the full SHA
    3748b30 View commit details
    Browse the repository at this point in the history
Loading