test: regression test for initialize hang on unexpected content-type
Closed
CH
3mo ago+107+107+012345678901234567890123456789-9-9-0123456789
Summary
- Adds a regression test (
test_initialize_does_not_hang_on_unexpected_content_type) that directly reproduces the hang described in issue #2432 - The test creates a minimal HTTP server that returns
Content-Type: text/plainfor all requests (includinginitialize) and asserts thatsession.initialize()raisesMCPErrorimmediately instead of blocking forever
The underlying fix is already present on main — _handle_post_request sends a proper JSONRPCError (with the matching request ID) when it encounters an unexpected content type, which lets ClientSession resolve the pending request instead of waiting indefinitely. This PR adds the missing test that exercises that code path for the initialize call specifically.
Test plan
-
tests/client/test_notification_response.py::test_initialize_does_not_hang_on_unexpected_content_type— new test passes - All existing
test_notification_response.pytests continue to pass
Fixes #2432