You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/08/04 02:48:31 UTC

[I] [BUG] MCP Streamable-HTTP session cleanup uses wrong key (auto-UUID) — sessions leak forever [shenyu]

Aias00 opened a new issue, #6833:
URL: https://github.com/apache/shenyu/issues/6833

   ## Description
   `ShenyuStreamableHttpServerTransportProvider.handleInitializeRequest` builds `new StreamableHttpSessionTransport()` (constructor sets `this.sessionId = UUID.randomUUID()` — the auto-UUID), but stores the session under `newSessionId = session.getId()` (the `McpServerSession`'s id, different from the transport's auto-UUID). `transport.close()`/`closeGracefully()` call `removeSession(this.sessionId)` (the auto-UUID), which removes nothing; the entries under `newSessionId` stay forever. There is also no TTL/eviction on `sessions`/`sessionTransports`/`ShenyuMcpExchangeHolder.EXCHANGE_MAP`.
   
   ## Location
   - `shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/transport/ShenyuStreamableHttpServerTransportProvider.java:321-329` (configureExchangeForSession + store under newSessionId), `1020-1023` (transport sessionId = auto-UUID), `1071-1088` (close/closeGracefully call removeSession(this.sessionId)), `763-766` (removeSession)
   
   ## Impact
   Unbounded memory growth / DoS — every Streamable-HTTP session leaks until process shutdown. (The temporary-session path at :433 correctly uses `session.getId()` for cleanup, which highlights that the permanent-session path is the bug.)
   
   ## Suggested fix
   Store sessions under the same key the transport uses for cleanup (or make `removeSession` look up by transport's sessionId); add a TTL/last-seen eviction sweep.
   
   ## Related existing
   Distinct from MCP-05 (#6644, `createSessionAndRestoreId` restore-path creation leak) — this is the main initialize-path cleanup-key mismatch plus total absence of expiry.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] MCP Streamable-HTTP session cleanup uses wrong key (auto-UUID) — sessions leak forever [shenyu]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #6833:
URL: https://github.com/apache/shenyu/issues/6833#issuecomment-5174027989

   👋 Hello @yuluo-yx
   
   A new issue has been opened by @Aias00:
   - **Title**: [BUG] MCP Streamable-HTTP session cleanup uses wrong key (auto-UUID) — sessions leak forever
   - **Link**: https://github.com/apache/shenyu/issues/6833
   
   Please review when you have time. Thank you! 🙏


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] MCP Streamable-HTTP session cleanup uses wrong key (auto-UUID) — sessions leak forever [shenyu]

Posted by "sunnysabor (via GitHub)" <gi...@apache.org>.
sunnysabor commented on issue #6833:
URL: https://github.com/apache/shenyu/issues/6833#issuecomment-5940631937

   I checked the current upstream implementation at `09c6a528` against the remaining lifetime concern in this issue. `sessions` and `sessionTransports` are `ConcurrentHashMap`s, and `ShenyuMcpExchangeHolder.EXCHANGE_MAP` is also a `ConcurrentHashMap`; there is no TTL or expiry sweep. Entries are removed on explicit `removeSession`/transport close and cleared on graceful shutdown.
   
   PR #6997 addresses the initialize-path key mismatch so explicit close can remove its entry, but a client that initializes a session and never sends DELETE/closes it can still retain all three map entries indefinitely. Please keep this expiry/lifetime concern visible as a separate follow-up or acceptance item if #6997 is merged, rather than treating the full issue as resolved by the key-alignment change alone.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] MCP Streamable-HTTP session cleanup uses wrong key (auto-UUID) — sessions leak forever [shenyu]

Posted by "zhang-arvin (via GitHub)" <gi...@apache.org>.
zhang-arvin commented on issue #6833:
URL: https://github.com/apache/shenyu/issues/6833#issuecomment-5462906076

   I will work on this.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] MCP Streamable-HTTP session cleanup uses wrong key (auto-UUID) — sessions leak forever [shenyu]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 closed issue #6833: [BUG] MCP Streamable-HTTP session cleanup uses wrong key (auto-UUID) — sessions leak forever
URL: https://github.com/apache/shenyu/issues/6833


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org