Skip to content

fix: reap completed response send tasks#1026

Merged
DaleSeo merged 1 commit into
modelcontextprotocol:mainfrom
N0zoM1z0:fix/reap-response-send-tasks
Jul 23, 2026
Merged

fix: reap completed response send tasks#1026
DaleSeo merged 1 commit into
modelcontextprotocol:mainfrom
N0zoM1z0:fix/reap-response-send-tasks

Conversation

@N0zoM1z0

Copy link
Copy Markdown
Contributor

Summary

  • reap completed response-send tasks during the main service loop
  • preserve concurrent response writes and the existing shutdown drain
  • log a join failure when a response-send task panics

Why

response_send_tasks currently retains every completed task until transport shutdown. A long-lived stdio server therefore grows resident memory with each request even though the response write has completed.

In a sequential 5,000-call stdio soak, one downstream server grew from 42.9 MiB RSS after warm-up to 60.3 MiB. Direct calls to its handler stayed flat, isolating the growth to the SDK serve loop. With this change, the same stdio workload stayed between 46.1 and 47.3 MiB.

Verification

  • cargo +1.97.0 fmt --all -- --check
  • cargo +1.97.0 check -p rmcp --features server,transport-io
  • cargo +1.97.0 test -p rmcp --features server,transport-io --test test_stdio_response_concurrency

@N0zoM1z0
N0zoM1z0 requested a review from a team as a code owner July 22, 2026 17:01
@github-actions github-actions Bot added the T-core Core library changes label Jul 22, 2026

@DaleSeo DaleSeo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix, @N0zoM1z0!

@DaleSeo
DaleSeo merged commit 50dd8e2 into modelcontextprotocol:main Jul 23, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants