Skip to content

Commit e0af8cd

Browse files
authored
HttpServletStreamableServerTransportProvider: avoid completing async context twice (#1308)
Close the session transport instead of the async context: close() is idempotent and swallows failures to complete the context. Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
1 parent 664e6f5 commit e0af8cd

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎mcp-core/src/main/java/io/modelcontextprotocol/server/transport/HttpServletStreamableServerTransportProvider.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,9 @@ else if (message instanceof McpSchema.JSONRPCRequest jsonrpcRequest) {
621621
}
622622
catch (Exception e) {
623623
logger.error("Failed to handle request stream: {}", e.getMessage());
624-
asyncContext.complete();
624+
// The transport may already have completed the async context, when
625+
// the failure comes from a message it could not send
626+
sessionTransport.close();
625627
}
626628
}
627629
else {

0 commit comments

Comments
 (0)