Skip to content

fix(core): a transfer cancelled before it starts spawns nothing, so it never connects - #11

Merged
RutaTang merged 1 commit into
mainfrom
claude/relaxed-cori-bw7sku
Oct 1, 2026
Merged

RutaTang merged 1 commit into
mainfrom
claude/relaxed-cori-bw7sku

Conversation

@RutaTang

@RutaTang RutaTang commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Summary

lsp::store::tests::downloads_are_https_only_and_cancellable went 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_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 locally.

Fix: transfer_on 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" promise rests on.

Regression test: net::tests::a_transfer_cancelled_before_it_starts_never_connects repeats 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 warnings
  • cargo fmt --all -- --check, rustdoc with -D warnings --document-private-items
  • stress: fix disabled → new test fails 101/137; fix enabled → 0/616
  • CI green on this PR

🤖 Generated with Claude Code

https://claude.ai/code/session_01WRJ4sDknvQJ86tFvGydgpf


Generated by Claude Code

…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
@RutaTang
RutaTang merged commit 15649c7 into main Oct 1, 2026
6 checks passed
@RutaTang
RutaTang deleted the claude/relaxed-cori-bw7sku branch October 1, 2026 03:01
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.

2 participants