fix(mcp): propagate abort signal to stop test execution#38939
Closed
mxschmitt wants to merge 1 commit intomicrosoft:mainfrom
Closed
fix(mcp): propagate abort signal to stop test execution#38939mxschmitt wants to merge 1 commit intomicrosoft:mainfrom
mxschmitt wants to merge 1 commit intomicrosoft:mainfrom
Conversation
| const { testRunner, screen, claimStdio, releaseStdio } = testRunnerAndScreen; | ||
|
|
||
| // Stop tests when the signal is aborted | ||
| const abortHandler = () => testRunner.stopTests(); |
Member
There was a problem hiding this comment.
That is a synchronous callback, nothing good will happen if you just fire and forget and then start over. You'll need to serialize all the calls to the backend to support this.
Contributor
Author
There was a problem hiding this comment.
Fixed. Now using Promise.race with proper await testRunner.stopTests(), and added a _queue in
TestContext (same pattern as TestRunner._queue) to serialize test operations. Please re-review.
83dd02e to
8b9c53b
Compare
- Pass AbortSignal from MCP SDK through to TestContext - Use Promise.race to handle abort during test execution - Add queue serialization in TestContext to ensure operations complete (including abort cleanup) before the next one starts - Properly await testRunner.stopTests() when aborted This addresses the concern about fire-and-forget abort handling. The queue ensures that if a second call arrives while the first is being aborted, it waits for the cleanup to complete. Co-Authored-By: Claude <noreply@anthropic.com>
8b9c53b to
0add62f
Compare
|
|
||
| if (status === 'paused') { | ||
| if (result.type === 'aborted') { | ||
| await testRunner.stopTests(); |
Member
There was a problem hiding this comment.
Consider the following use case:
- client runs tests
- global setup runs
- tests start to run
- client aborts the run
- client initiates new test run w/o waiting as per spec
- global setup runs
- testRunner.stop run in line 253
- global teardown runs
Member
|
Closing as stale |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an MCP tool call is aborted (e.g., user cancels in Claude Code or another MCP client), the abort signal from the MCP SDK was not being propagated to the test runner, causing tests to continue running even after the call was cancelled.
This change:
signal: AbortSignalparameter toServerBackend.callToolextra.signalfrom MCP SDK request handler to backendsrunTestsWithGlobalSetupAndPossiblePauseand callstestRunner.stopTests()when abortedFixes #38937