Skip to content

Stop heartbeats after a failed connection closes - #326

Merged
varun06 merged 1 commit into
modelcontextprotocol:mainfrom
EhsanAzish80:fix/network-heartbeat-failure
Nov 8, 2026
Merged

varun06 merged 1 commit into
modelcontextprotocol:mainfrom
EhsanAzish80:fix/network-heartbeat-failure

Conversation

@EhsanAzish80

Copy link
Copy Markdown
Contributor

When repeated empty reads find a failed connection, the receive loop cancels it but leaves the transport connected. Heartbeats can keep sending after the socket closes. This also caused the macOS CI failure seen on #307.

Mark the transport disconnected and cancel its heartbeat task in that path. The new test covers the empty-read failure and checks that sends are rejected and heartbeats stop.

Tests: the new test failed on unchanged main (19 sends after cancellation). All 18 network tests and the full 580-test suite passed with the fix on c0ff1e6. AI helped write the new test; I ran it.

@EhsanAzish80
EhsanAzish80 requested a review from a team as a code owner November 8, 2026 09:01
@varun06
varun06 merged commit b9778b0 into modelcontextprotocol:main Nov 8, 2026
6 checks passed
@EhsanAzish80
EhsanAzish80 deleted the fix/network-heartbeat-failure branch November 8, 2026 17:34
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.

2 participants