Repository navigation
fix(core): a transfer cancelled before it starts spawns nothing, so it never connects - #11
Merged
Merged
Conversation
…t never connects `lsp::store::tests::downloads_are_https_only_and_cancellable` went red on main's CI (run 55) with "a cancelled download connected", and passed on the re-run. The race is the transport's: `transfer_on` spawned the download thread first and looked at `cancel` only in the loop after it. The thread watches `stop`, which `Abandon` raises as the function returns — after that look — so with the flag already up, a thread scheduled ahead of its caller was past its own check and on the wire before `stop` was set. Under CPU load the store test failed 64 times in 4583 runs here. `transfer_on` now reads `cancel` before spawning: a transfer already cancelled starts no thread and makes no connection, which is what `fetch`'s "no connection is even attempted" rests on. A regression test in `net` repeats a cancelled-at-entry transfer against a listener that must see nothing; without the fix it fails 101 runs in 137 under load, with it neither test failed in 616. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WRJ4sDknvQJ86tFvGydgpf
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.
Summary
lsp::store::tests::downloads_are_https_only_and_cancellablewent red on main's CI run 55 ("a cancelled download connected") and passed on the re-run. The race is the transport's, not the test's:net::transfer_onspawned the download thread first and looked atcancelonly in the loop after it.stop, whichAbandonraises as the function returns — after that look — so with the flag already up, a thread scheduled ahead of its caller was past its own check and on the wire beforestopwas set.Fix:
transfer_onreadscancelbefore spawning. A transfer already cancelled starts no thread and makes no connection, which is whatfetch's "no connection is even attempted" promise rests on.Regression test:
net::tests::a_transfer_cancelled_before_it_starts_never_connectsrepeats a cancelled-at-entry transfer 200× against a listener that must see nothing. Without the fix it fails 101 runs in 137 under load; with it, neither test failed in 616.Test plan
cargo test -p clew-core --lib— 651 passed (git 2.55 on PATH, matching the runners)cargo clippy -p clew-core --all-targets -- -D warningscargo fmt --all -- --check, rustdoc with-D warnings --document-private-items🤖 Generated with Claude Code
https://claude.ai/code/session_01WRJ4sDknvQJ86tFvGydgpf
Generated by Claude Code