Repository navigation
fix(server): a queued /v1 run no longer takes over the running one's cancel and asks - #515
Merged
Merged
Conversation
…cancel and asks run registered its cancel flag and event sink per session id before the task took the session lock. A second run for the same session replaced the running one's entries: cancel stopped the queued run instead of the running one, the running turn's permission asks went to the second client's stream, and the first run's cleanup then removed the queued run's entries, leaving it uncancellable with asks nobody received. A run now registers once it holds the session and unregisters before releasing it. An uncontended run still takes the lock in the handler, so cancel works as soon as run has answered. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Merged
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.
Problem
POST /v1/sessions/:id/runregistered its cancel flag and event sink in per-session maps before its task took the session lock. With a run in flight, a second run for the same session replaced those entries:cancelstopped the queued run instead of the running one.Fix
A run registers once it holds the session and unregisters before releasing it (
own_run). An uncontended run still takes the lock inside the handler, socancelworks as soon asrunhas answered, as before. Runs on one session still queue; that is unchanged.A queued run cannot be cancelled until it starts. Before this change a cancel in that window hit the queued run by accident; now it reaches the running one.
Verification
a_queued_run_does_not_take_over_the_running_onefails onmain(cancel does not reach the running run's flag) and passes here.cargo test -p whycodes-server: 95 passed. Clippy, fmt, budget scripts: green.cargo llvm-cov clean, no uncovered lines. The fullscripts/coverage.shworkspace run was not done locally.docs/knowhow.mdhas the entry.🤖 Generated with Claude Code