fix: enforce retry limit when SSE stream makes no progress#742
Merged
maciej-kisiel merged 4 commits intomodelcontextprotocol:mainfrom Feb 3, 2026
Conversation
…extprotocol#679) Previously, the StreamableClientTransport retry counter would reset whenever a connection was re-established, which could lead to infinite retry loops if a server continuously terminates connections without making progress (advancing the Last-Event-ID). This change tracks progress across retry attempts in handleSSE: - The retry counter is only reset when the Last-Event-ID advances - If maxRetries is exceeded without progress, the connection fails - This implements Option 2 from the issue discussion 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: majiayu000 <1835304752@qq.com>
Contributor
|
Thanks for this contribution, and sorry for the delay. I'll be catching up on PRs this weekend / next week. |
findleyr
reviewed
Jan 3, 2026
Contributor
findleyr
left a comment
There was a problem hiding this comment.
Thanks, this looks good. Just a couple nits in the test.
| } | ||
|
|
||
| // Verify that we actually retried the expected number of times. | ||
| // We expect maxRetries+1 attempts because we increment before checking the limit. |
Contributor
There was a problem hiding this comment.
In this case, make this more assertive: assert that got == maxRetries+1
mcp/streamable_client_test.go
Outdated
Contributor
There was a problem hiding this comment.
const maxRetries = 2
(more readable, and avoids some conversions below)
scutuatua-crypto
approved these changes
Jan 10, 2026
maciej-kisiel
previously approved these changes
Jan 29, 2026
maciej-kisiel
approved these changes
Jan 29, 2026
findleyr
approved these changes
Feb 3, 2026
Contributor
findleyr
left a comment
There was a problem hiding this comment.
Thanks! @maciej-kisiel feel free to merge.
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 #679
Changes
This implements Option 2 from the issue: progress-based retry limiting that prevents infinite retry loops while allowing long-running streams to continue as long as progress is made.