Skip to content

Close SSE transports on timeout/error and evict sessions with failed SSE writes - #6867

Closed
ikaitist wants to merge 1 commit into
spring-projects:mainfrom
ikaitist:fix/mcp-webmvc-sse-cleanup
Closed

ikaitist wants to merge 1 commit into
spring-projects:mainfrom
ikaitist:fix/mcp-webmvc-sse-cleanup

Conversation

@ikaitist

Copy link
Copy Markdown

Fixes #6860

What

WebMvcStreamableServerTransportProvider leaks SSE sockets when clients disconnect without DELETE. Two gaps fixed:

  • sseBuilder.onTimeout only logged; onError was not handled at all. Both now close the session transport, freeing the socket immediately.
  • notifyClients logged send failures and kept dead sessions. A failed SSE write now evicts the session (removeSession + closeGracefully).

Session slots for silent clients remain covered by the existing idle eviction (sessionIdleTimeout).

How verified

  • Syntax-checked locally; module tests run in CI (local reactor build is blocked by milestone repository access from the contributor network).

…SSE writes

Signed-off-by: ikaitist <qiujin9@foxmail.com>
@ikaitist
ikaitist force-pushed the fix/mcp-webmvc-sse-cleanup branch from 959eccb to d159d17 Compare September 3, 2026 01:37
@sobychacko

Copy link
Copy Markdown
Contributor

Thanks for this, @ikaitist. This overlaps heavily with #6871, which targets the same issue (#6860) and takes a broader pass at the same fix: it unifies the onComplete, onTimeout, and onError callbacks through a single idempotent close() and also covers the request-response streaming and replay error paths, plus it adds unit tests. One notable difference is session handling on an SSE write failure. This PR evicts the logical session via removeSession and closeGracefully, whereas #6871 intentionally closes only the current transport so that the same mcp-session-id and Last-Event-ID replay keep working on subsequent requests, deferring eviction to DELETE or keep-alive. Given that overlap we plan to proceed with #6871 and close this one. We really appreciate you digging into the socket leak, and we would welcome your review on #6871 and any future contributions.

@sobychacko sobychacko closed this Sep 15, 2026
@sobychacko sobychacko added duplicate This issue or pull request already exists and removed status: waiting-for-triage labels Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] WebMvcStreamableServerTransportProvider: session and socket leak when clients disconnect without DELETE

3 participants