Skip to content

Improve testing for StreamableHttpHandler and IdleTrackingBackgroundService #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 24, 2025

Conversation

halter73
Copy link
Contributor

@halter73 halter73 commented Apr 23, 2025

  • Increase default IdleTimeout from 2 minutes to two hours
  • Make MaxIdleSessionCount configurable and keep the default to 10,000.
  • Remove redundant CTS from StreamableHttpHandler
    • StreamableHttpServerTransport.HandlePostRequest already creates the equivalent CTS which DeleteRequest_CompletesSession_WhichCancelsLongRunningToolCalls verifies
  • Better test IdleTrackingBackgroundService and delete least recently active idle session first when the MaxIdleSessionCount is exceeded.

- StreamableHttpServerTransport.HandlePostRequest already creates the equivelant CTS
  which DeleteRequest_CompletesSession_WhichCancelsLongRunningToolCalls verifies
…oc comments

- This makes sense if the consumer of the API hasn't started the transport or something
- This makes less sense if the other side of the connection closed the transport which should be an IOException
- Or the consumer disposed the transport which should be an ObjectDisposedException

- However this PR isn't prescriptive. It's just matching the doc comments to the current behavior
- Fix flaky Cancellation_ThrowsCancellationException test
@halter73 halter73 merged commit e3ff552 into modelcontextprotocol:main Apr 24, 2025
7 checks passed
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.

3 participants