Skip to content

fix: start the Timeout thread before the tests run - #740

Merged
koic merged 1 commit into
modelcontextprotocol:mainfrom
yorzi:fix/timeout-thread-in-thread-list-tests
Dec 1, 2026
Merged

koic merged 1 commit into
modelcontextprotocol:mainfrom
yorzi:fix/timeout-thread-in-thread-list-tests

Conversation

@yorzi

@yorzi yorzi commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Five tests no longer depend on the test order: test/test_helper.rb starts the thread Timeout keeps for the process before any test runs.

Fixes #739

Motivation and Context

The five tests named in the issue compare Thread.list before and after a step. Timeout.timeout starts a thread on first use and keeps it, so whichever of them is the first to reach a bounded stream write counts that thread as one the transport started. It failed the Ruby 3.1 job of #736 and the Ruby 3.4 job of #738.

#542 made one of these assertions compare the set of threads instead of their count, which holds as long as only the transport can add a thread. The writes bounded by stream_write_timeout add the Timeout thread. Starting it up front restores that assumption for all five, and for tests added later. No library code changes.

How Has This Been Tested?

bundle exec rake test (2,815 tests, 10,202 assertions, under each of eight seeds), bundle exec rake rubocop, bundle exec yard --no-output and bundle exec rake conformance:test (baseline) pass locally on Ruby 4.0.9.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Test update (non-breaking change which adds or updates tests)
  • Refactoring (non-breaking change which makes things better)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • CI/build script update (update CI workflow or build scripts)

Checklist

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

Timeout starts one thread for the process on first use and keeps it.
Tests that compare thread lists took it for a thread the transport had
left behind whenever they were the first to use it.

Fixes modelcontextprotocol#739.
@koic
koic merged commit b789aea into modelcontextprotocol:main Dec 1, 2026
13 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.

Tests that compare thread lists fail when they are the first to use Timeout

2 participants