Skip to content

[Client] Implement setMaxRetries connection retries - #413

Open
chr-hertel wants to merge 6 commits into
modelcontextprotocol:mainfrom
chr-hertel:fix/client-max-retries
Open

[Client] Implement setMaxRetries connection retries#413
chr-hertel wants to merge 6 commits into
modelcontextprotocol:mainfrom
chr-hertel:fix/client-max-retries

Conversation

@chr-hertel

Copy link
Copy Markdown
Member

Client\Builder::setMaxRetries() has never had an implementation — it was added in the initial client commit, stored on Configuration, and read by nothing, so the documented "retry attempts for failed connections" never happened.

Client::connect() now retries a failed attempt, closing the transport in between so a retry gets a fresh process / drops the failed HTTP session, with a short linear backoff. The value counts retries rather than attempts, and 0 disables retrying.

This also fixes a prerequisite bug in Client\Protocol::request(): only the response path cleared a pending request, so one that timed out stayed pending forever and made every following request fail as timed out immediately — which would have made retries useless on the timeout path.

@chr-hertel chr-hertel added bug Something isn't working Client Issues & PRs related to the Client component labels Aug 10, 2026
@chr-hertel chr-hertel added this to the 0.8.0 milestone Aug 10, 2026
@chr-hertel
chr-hertel requested a balanced review from Copilot August 10, 2026 23:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Implements configurable client connection retries and fixes stale pending requests after timeouts.

Changes:

  • Adds connection retry, cleanup, and linear backoff behavior.
  • Validates retry configuration and documents its semantics.
  • Adds unit coverage for retries, exhaustion, and timeout recovery.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Client.php Implements connection retries and backoff.
src/Client/Builder.php Clarifies retry configuration semantics.
src/Client/Configuration.php Rejects negative retry counts.
src/Client/Protocol.php Cleans up pending requests reliably.
tests/Unit/ClientTest.php Tests connection retry behavior.
docs/client.md Documents connection retries.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Client.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Client Issues & PRs related to the Client component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants