Skip to content

Add regression tests for #559 and #555 #1044

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

felixweinberger
Copy link
Contributor

@felixweinberger felixweinberger commented Jun 26, 2025

Motivation and Context

#559 and #555 address important but different ways MCP servers can hang if they don't respect SIGTERM or SIGINT.

This PR adds regressions tests to clearly demonstrate the edge cases addressed by #559 and #555.

How Has This Been Tested?

See tests introduced in the 2nd commit.

I reverted the changes in both #555 and #559 to verify that all 3 tests FAIL without them:

macOS Windows
CleanShot 2025-06-26 at 22 16 38@2x CleanShot 2025-06-26 at 22 26 54@2x

#559 makes the first 2 tests pass, but not the third (because it doesn't solve SIGINT):

macOS Windows
CleanShot 2025-06-26 at 22 16 13@2x CleanShot 2025-06-26 at 22 26 02@2x

#555 also makes the third test pass (no test for Windows because signals handled differently, so this test is skipped on Windows)

CleanShot 2025-06-26 at 22 15 42@2x

I ran the tests on both macOS and Windows.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@felixweinberger felixweinberger force-pushed the fweinberger/stream-cleanup-only-approach branch from 1ab6f36 to 9f88ea7 Compare June 26, 2025 21:29
@felixweinberger felixweinberger force-pushed the fweinberger/stream-cleanup-only-approach branch from 9f88ea7 to a27fcef Compare June 26, 2025 21:31
@felixweinberger felixweinberger force-pushed the fweinberger/stream-cleanup-only-approach branch 3 times, most recently from 785386a to 543e1ad Compare June 26, 2025 21:47
**NOTE: These tests FAIL without the changes introduced in #559**

- test_stdio_client_universal_timeout
- test_stdio_client_immediate_completion

await read_stream.aclose()
await write_stream.aclose()
await read_stream_writer.aclose()
await write_stream_reader.aclose()

These tests verify that stdio_client completes cleanup within reasonable
time for both slow-terminating and fast-exiting processes, preventing
the hanging issues reported in #559.

**NOTE: This test FAILS without the changes introduced in #555**

- test_stdio_client_sigint_only_process

try:
    process.terminate()
    with anyio.fail_after(2.0):
        await process.wait()
except TimeoutError:
    # If process doesn't terminate in time, force kill it
    process.kill()

This test verifies that on UNIX systems MCP servers that don't respect
SIGTERM but e.g. SIGINT still get terminated after a grace period.
@felixweinberger felixweinberger force-pushed the fweinberger/stream-cleanup-only-approach branch 2 times, most recently from 98012bf to caa5628 Compare June 26, 2025 21:54
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.

1 participant