Skip to content

HttpServletStreamableServerTransportProvider: server-initiated requests race client stream registration (intermittent -32603 "Stream unavailable") #1114

Description

@slachiewicz

Summary

HttpServletStreamableServerTransportProvider intermittently answers -32603 "Stream unavailable for session <id>" (wrapped as JSON-RPC internal error / HTTP 500) when it attempts to push a server-initiated request (e.g. roots/list) to a client whose GET /mcp SSE stream has not been registered yet.

Observed failure

  • Test: HttpServletStreamableIntegrationTests.testRootsNotificationWithEmptyRootsList(String)[1]
  • CI run: https://github.com/modelcontextprotocol/java-sdk/actions/runs/33068920136 (Build and Test)
  • Client-side surfacing: java.lang.RuntimeException: Failed to send message: AggregateResponseEvent[...] wrapping
    jsonRpcError: {"code":-32603,"message":"Error processing message: Stream unavailable for session 82454020-4c10-4276-9c30-57c15d49810e"}

Repro shape

  1. Client declares the roots capability
  2. Client sends initialize; server accepts and creates the session
  3. Server immediately pushes roots/list over the session's GET /mcp stream
  4. POST traffic racing the first stream registration loses → -32603, stream unavailable

Why we believe it is a race (not environment-specific)

Suggested directions

  1. Buffer server→client messages per session until a stream registers (short grace window), or
  2. Single retry on "stream unavailable" for capability-prompted pushes

A test-side await cannot fix this, since the failure occurs inside the server's push path.

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions