Skip to content

Test the wake-up of the backoff wait without replacing ConditionVariable.new - #741

Open
koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:test_the_wake_up_of_the_backoff_wait_without_replacing_condition_variable_new
Open

koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:test_the_wake_up_of_the_backoff_wait_without_replacing_condition_variable_new

Conversation

@koic

@koic koic commented Dec 1, 2026

Copy link
Copy Markdown
Member

Motivation and Context

test_input_required_cancellation_wakes_the_backoff_wait, added in #730, replaced ConditionVariable.new for the whole process while it ran. The second call and every later one, from any thread and from Monitor#new_cond as well, returned one condition variable whose wait ignored its timeout, and the test counted on the client creating exactly one condition variable before the backoff wait. A thread that created one at that moment got the wrong object, so the test could fail, or leave that thread waiting, depending on what else was running.

Two tests replace it and leave the class alone. One enters the backoff wait directly, for far longer than the test may take, and cancels once the thread sleeps, so only a wake-up ends it in time. The other cancels as the hook of the backoff wait is registered during a call_tool, whatever the timing, and checks that the call raises CancelledError with the reason and sends no further request.

Follow-up to #730.

How Has This Been Tested?

test/mcp/client_test.rb. The first test fails without the signal in the hook of the backoff wait, and the second without the check that precedes each request.

Breaking Changes

None. Only tests change.

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

…able.new`

## Motivation and Context

`test_input_required_cancellation_wakes_the_backoff_wait`, added in modelcontextprotocol#730, replaced `ConditionVariable.new`
for the whole process while it ran. The second call and every later one, from any thread and from `Monitor#new_cond` as well,
returned one condition variable whose `wait` ignored its timeout, and the test counted on the client creating
exactly one condition variable before the backoff wait. A thread that created one at that moment got the wrong object,
so the test could fail, or leave that thread waiting, depending on what else was running.

Two tests replace it and leave the class alone. One enters the backoff wait directly, for far longer than the test may take,
and cancels once the thread sleeps, so only a wake-up ends it in time. The other cancels as the hook of the backoff wait
is registered during a `call_tool`, whatever the timing, and checks that the call raises `CancelledError` with the reason
and sends no further request.

Follow-up to modelcontextprotocol#730.

## How Has This Been Tested?

`test/mcp/client_test.rb`. The first test fails without the signal in the hook of the backoff wait,
and the second without the check that precedes each request.

## Breaking Changes

None. Only tests change.

This branch has not been deployed

No deployments
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