Skip to content

Conversation

@majiayu000
Copy link

Fixes #679

Changes

  • Track last event ID to detect progress in SSE streams
  • Only reset retry counter when Last-Event-ID advances
  • Fail connection after exceeding maxRetries without progress

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.

…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>
@findleyr
Copy link
Contributor

findleyr commented Jan 2, 2026

Thanks for this contribution, and sorry for the delay. I'll be catching up on PRs this weekend / next week.

@findleyr findleyr self-requested a review January 2, 2026 18:11
Copy link
Contributor

@findleyr findleyr left a 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.
Copy link
Contributor

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


// Use the fakeStreamableServer pattern like other tests to avoid race conditions.
ctx := context.Background()
maxRetries := 2
Copy link
Contributor

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)

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.

Set a total retry limit on streams, or enforce progress

2 participants