Skip to content

fix(streamable-http): count bare-priming-then-EOF reconnects against … - #3323

Closed
gingeekrishna wants to merge 2 commits into
modelcontextprotocol:mainfrom
gingeekrishna:fix/3307-eof-reconnect-budget
Closed

fix(streamable-http): count bare-priming-then-EOF reconnects against …#3323
gingeekrishna wants to merge 2 commits into
modelcontextprotocol:mainfrom
gingeekrishna:fix/3307-eof-reconnect-budget

Conversation

@gingeekrishna

Copy link
Copy Markdown

…the request budget

A reconnect that reaches EOF without delivering any real data (only a bare id-bearing priming event) was resetting the attempt counter to 0 instead of incrementing it. This let a server that repeatedly opened the resumable stream, emitted only a priming event, and closed again reconnect forever rather than giving up after MAX_RECONNECTION_ATTEMPTS and resolving the waiter with CONNECTION_CLOSED.

Track whether any event with non-empty data was received during the reconnect. A reconnect that made real progress (delivered a notification) still earns a fresh budget for the next reconnect; a reconnect that saw only bare priming events counts against the budget the same way a transport exception does.

Adds a regression test that drives _handle_reconnection with a mock transport returning priming-then-EOF on every reconnect and asserts the waiter resolves with CONNECTION_CLOSED after exactly MAX_RECONNECTION_ATTEMPTS attempts.

Fixes #3307

Motivation and Context

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

…the request budget

A reconnect that reaches EOF without delivering any real data (only a bare
id-bearing priming event) was resetting the attempt counter to 0 instead of
incrementing it. This let a server that repeatedly opened the resumable stream,
emitted only a priming event, and closed again reconnect forever rather than
giving up after MAX_RECONNECTION_ATTEMPTS and resolving the waiter with
CONNECTION_CLOSED.

Track whether any event with non-empty data was received during the reconnect.
A reconnect that made real progress (delivered a notification) still earns a
fresh budget for the next reconnect; a reconnect that saw only bare priming
events counts against the budget the same way a transport exception does.

Adds a regression test that drives _handle_reconnection with a mock transport
returning priming-then-EOF on every reconnect and asserts the waiter resolves
with CONNECTION_CLOSED after exactly MAX_RECONNECTION_ATTEMPTS attempts.

Fixes modelcontextprotocol#3307
@gingeekrishna
gingeekrishna marked this pull request as ready for review August 19, 2026 19:08
Copilot AI lite review requested due to automatic review settings August 19, 2026 19:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Aug 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This repository only keeps pull requests open when they're linked to an issue that a maintainer has assigned to the author — CONTRIBUTING.md explains why and how we work. This PR has been closed for now because you aren't currently assigned to #3307.

If a maintainer would like this change as a PR from you, they'll assign you to #3307 and this PR will reopen automatically — there's nothing more you need to do. (If you opened the issue, this PR already shows up on its timeline.)

There's no need to open a new PR — this one will be reopened. While it's closed, please push any updates as new commits rather than force-pushing, since GitHub can't reopen a PR whose branch has been rewritten.

Maintainers: reopening this PR, removing the missing-issue-link label, or adding bypass-issue-check bypasses the check.

@github-actions github-actions Bot closed this Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamable HTTP clean EOF reconnects can exceed the request retry budget

2 participants