fastmcp/tests
Chris Guidry 5d84a3773e Fix MCPConfigTransport subprocess resource leak
Test `test_multi_client_lifespan` was timing out because MCPConfigTransport leaked subprocess resources.

**Root cause:** MCPConfigTransport.connect_session() never cleaned up underlying StdioTransport objects. When the client context exited, only the main FastMCPTransport session was closed, but the underlying stdio connections to actual MCP server subprocesses were left open. With keep_alive=True (default), these transports don't auto-disconnect, so subprocess stdin was never closed and processes stayed alive indefinitely.

**The fix:** Added finally block to MCPConfigTransport.connect_session() that explicitly calls close() on all underlying transports. This ensures subprocess stdin is closed and processes terminate cleanly.

**Evidence:**
- Before: 100% timeout rate (processes status='sleeping' after context exit)
- After: 15/15 consecutive passes, processes terminate immediately
- Test time: 5.2s (timeout) → 3.2s (clean exit)

**Secondary fix:** Simplified test logic from infinite polling loop to direct psutil.Process(pid).status() check. The old while-True loop never raised NoSuchProcess because the constructor succeeds for existing processes.

All 3271 tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 10:10:39 -05:00
..
cli Fix: URL-encode server name in Cursor deeplinks (#2369) 2025-11-04 11:26:57 -05:00
client Exclude MCP SDK 1.21.1 and update OAuth client tests 2025-11-15 12:21:15 -05:00
contrib feat: Add title, annotations and meta to mixin decorators 2025-10-10 14:23:02 +05:30
deprecated feat: introduce fastmcp.json configuration system (#1517) 2025-08-19 16:06:04 -04:00
experimental Bump ty to ==0.0.1a25 (#2350) 2025-11-02 20:02:45 -05:00
integration_tests Fix typos and formatting 2025-11-15 12:21:15 -05:00
prompts Enable more type checking rules (#1775) 2025-09-07 11:11:44 -04:00
resources Fix query-only resource templates not matching URIs without query strings (#2323) 2025-11-01 11:27:37 -04:00
server Merge pull request #2439 from jlowin/oidc-proxy-extra-params 2025-11-17 12:23:11 -05:00
tools Fix type errors in oauth_proxy and test_auth_integration 2025-11-15 12:21:15 -05:00
utilities Fix duplicate keyword argument error in configure_logging (#2381) 2025-11-06 10:11:16 -05:00
__init__.py Update type handling for resources 2024-11-29 19:42:46 -05:00
conftest.py Fix Windows test timeouts from SQLite locking (#2368) 2025-11-04 10:58:49 -05:00
test_examples.py Cleanup content conversion 2025-09-06 17:32:33 -05:00
test_mcp_config.py Fix MCPConfigTransport subprocess resource leak 2025-11-21 10:10:39 -05:00