Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1331
SSEClientTransport.Connect used the context passed to it for the long-lived event stream. If the caller bounded the handshake with a timeout or cancelled it afterwards, the stream closed and later calls failed. StreamableClientTransport does not behave this way.
This change makes the stream independent of the Connect context. The context now only bounds the handshake: if it is cancelled before the handshake completes, Connect returns the error and cleans up the request. After Connect returns, the stream is cancelled only by Close.
Testing: added
TestSSEClientConnectContextCanceledinmcp/sse_test.go. It cancels the Connect context after connecting and checks that a later Ping succeeds. The test and the project's checks pass.I use the usual pattern of a timeout context for Connect, and it broke the SSE session without any warning. The streamable transport works with the same code, so I wanted both to behave the same.