Skip to content

Fix: Replace Mono.zip with Mono.when in StdioServerTransportProvider#sendMessage#846

Open
rameshreddy-adutla wants to merge 1 commit intomodelcontextprotocol:mainfrom
rameshreddy-adutla:fix/303-mono-zip-to-when
Open

Fix: Replace Mono.zip with Mono.when in StdioServerTransportProvider#sendMessage#846
rameshreddy-adutla wants to merge 1 commit intomodelcontextprotocol:mainfrom
rameshreddy-adutla:fix/303-mono-zip-to-when

Conversation

@rameshreddy-adutla
Copy link

Summary

Replaces Mono.zip() with Mono.when() in StdioMcpSessionTransport#sendMessage to correctly wait for both inbound and outbound ready signals before sending messages.

Problem

Mono.zip() on Mono<Void> sources cancels the slower publisher when the faster one completes empty. As explained by @chemicL, this means the slower of the two ready signals (inboundReady or outboundReady) gets cancelled instead of being awaited.

Fix

Changed Mono.zip(inboundReady.asMono(), outboundReady.asMono()) to Mono.when(inboundReady.asMono(), outboundReady.asMono()) which properly waits for all sources to complete before proceeding.

Testing

All 9 existing StdioServerTransportProviderTests pass.

Fixes #303

…sendMessage

Mono.zip() on Mono<Void> sources cancels the slower publisher when the
faster one completes empty, which can cause the inbound or outbound
ready signal to be prematurely cancelled. Mono.when() correctly waits
for all sources to complete before proceeding.

Fixes modelcontextprotocol#303

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StdioServerTransportProvider uses incorrect Mono.zip operator

1 participant