Skip to content

Fix client transport leak on reconnect - #614

Open
Adebayo120 wants to merge 1 commit into
modelcontextprotocol:mainfrom
Adebayo120:fix/client-close-transport-on-reconnect
Open

Adebayo120 wants to merge 1 commit into
modelcontextprotocol:mainfrom
Adebayo120:fix/client-close-transport-on-reconnect

Conversation

@Adebayo120

Copy link
Copy Markdown
Contributor

Summary

  • Close the client's currently owned transport before replacing it in connect().
  • Add a regression test that verifies reconnect closes the old transport and disconnect() closes the replacement.
  • Document the reconnect cleanup behavior.

Reproduction

Connect one Client to a first transport, call connect() again with a second transport, then call disconnect(). Before this change, the first transport's close() is never called; only the second transport is closed, potentially leaving the old server process or HTTP session/stream active.

Validation

  • php vendor/bin/phpunit tests/Unit/Client (803 tests)
  • PHPStan on the changed client and unit test
  • PHP-CS-Fixer dry run on changed PHP files

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

1 participant