-
Notifications
You must be signed in to change notification settings - Fork 334
fix: enforce retry limit when SSE stream makes no progress #742
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
base: main
Are you sure you want to change the base?
fix: enforce retry limit when SSE stream makes no progress #742
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>
|
Thanks for this contribution, and sorry for the delay. I'll be catching up on PRs this weekend / next week. |
findleyr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, make this more assertive: assert that got == maxRetries+1
mcp/streamable_client_test.go
Outdated
|
|
||
| // Use the fakeStreamableServer pattern like other tests to avoid race conditions. | ||
| ctx := context.Background() | ||
| maxRetries := 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const maxRetries = 2
(more readable, and avoids some conversions below)
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.