Skip to content

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

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

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

Conversation

@rameshreddy-adutla

Copy link
Copy Markdown
Contributor

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

Mono.zip cancels the slower Mono<Void> source when the faster one
completes empty, so sendMessage could proceed before both inbound and
outbound readiness signals fired. Mono.when waits for both. Fixes modelcontextprotocol#303.

This branch has not been deployed

No deployments
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