Repository navigation
fix(BAR-34): Stops a cancelled MCP call at once, even before its query starts - #42
Merged
Merged
Conversation
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.
📝 What changed?
A cancel from an AI assistant was lost when it arrived before the call's query had registered, for example while the server was still reloading the saved connections.
cancel_queryfound nothing to stop, so the query started anyway and ran to the end, holding its connection (SQLite's only one) the whole time. Nowcall()races the tool against the cancel withtokio::select!, so every tool exceptrun_changestops the moment it's cancelled. A cancelled call still gets no answer.run_changekeeps its own handling, which takes its approval question down or rolls the change back.wait_forreturnsErr. TheOk(_)pattern skips that, so the older call keeps running.🧩 Type of change
🧪 Tested
📖 Docs
📌 Notes
This race made
a_reused_request_id_leaves_the_newer_call_cancellablefail once in the Linux E2E job on #41 (run), where the cancel came before the endless query had registered. The new testa_cancel_before_the_query_registers_still_stops_itholds the engines lock so a call parks before its query registers. It then cancels the call and checks that it settles without an answer. Without the fix it fails with "the cancel was lost".