Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid race starting SseResponseStreamTransport #91

Merged
merged 1 commit into from
Mar 25, 2025

Conversation

halter73
Copy link
Contributor

The logging from https://github.com/modelcontextprotocol/csharp-sdk/actions/runs/14040589658/job/39309497411 indicates that one source of test flakiness is a real product issue.

_sseWriteTask might not be set until after the SSE endpoint event has already been sent since SseFormatter.WriteAsync does not return a task until it awaits. This means that it's possible for the client to find the "/message" endpoint and send a message to that before IsConnected is true which can lead to an improper InvalidOperationException as seen in the logs.

@halter73 halter73 requested a review from stephentoub March 25, 2025 00:43
@stephentoub stephentoub merged commit 367f265 into modelcontextprotocol:main Mar 25, 2025
7 checks passed
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.

2 participants