Repository navigation
test(locallibrary): stop reading a cancelled upload until publishing stops - #317
Merged
Merged
Conversation
bnb
approved these changes
Oct 30, 2026
botandbang
enabled auto-merge
October 30, 2026 16:31
Rust coverageFrom run 562. Both are held to the thresholds in .cargo/config.toml.
|
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 and why
The upload-cancel test still failed under load after #278. Its server read 8 KiB every 10 ms, and the test gave the server 10 s to see the connection close. The host stops sending at its next chunk once the cancel reaches it. But what it sent before the cancel still sits in the socket buffers (0.7 to 1 MB here, up to several MiB with macOS autotuning), and at that read rate draining it took 1.4 s on an idle machine and more than 10 s under load. A 15x slower server reproduces the timeout.
Reading at full speed isn't enough on its own: the cancel goes from the host to the plugin and back to the host's
net/fetchbefore the upload sees it, and under load a fast server takes the whole 32 MiB before then.Now the server reads once, cancels, and reads nothing more until publishing has returned. Until then the host can only fill the buffers. Then it reads the rest at once, stopping at EOF or the full size, and the test joins it for the byte count. That works because the plugin passes the cancel on to its
net/fetchbefore it answers the hook, so by the time publishing returns the upload has been told to stop. The 10 seventually, the per-read sleep, and the two atomics are gone.Fixes LOC-108
How it was tested
cargo fmt --check, andcargo clippy -p locallibrary --all-targets -- -D warnings.cargo nextest run -p locallibrary --test it --retries 0onplugins::destinations::: 11 pass.plugins::tests at--test-threads 8(load 60 to 112): all passed, with at most 680 KB of the 32 MiB read. The 196 passed too.Sending::read, it passes in 1.4 s.Checklist