Skip to content

test(locallibrary): cancel a publish only once its upload is being sent - #278

Merged
botandbang merged 2 commits into
mainfrom
bnb/cancelled-upload
Oct 29, 2026
Merged

botandbang merged 2 commits into
mainfrom
bnb/cancelled-upload

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

What and why

plugins::destinations::a_recording_stops_being_sent_once_publishing_is_cancelled failed now and then on macOS CI, waiting 10 s for "the upload stopped" (main, 10-26, #268). It cancelled publishing on a 300 ms timer, and under load that timer can go off before the host has sent the request. Then nothing is uploaded, the test's server waits in accept() forever, and the wait times out. Setting the timer to 0 ms reproduces it every time, with the same 10.7 s failure.

The test now creates the cancel token before its server thread, and the server cancels once it has received the first bytes of the recording, so the cancel always lands on an upload that's being sent. The 300 ms timer thread is gone. Every assertion is unchanged: publishing answers cancelled, the server sees the upload end, less than half the recording was sent, and the set has no link. No library code changes. In every passing run before this change, the host's body reader stopped on the cancel and the server saw the connection close.

How it was tested

Stress runs of the one test with cargo nextest run -p locallibrary --test it -E 'test(a_recording_stops_being_sent_once_publishing_is_cancelled)' --stress-count N:

  • Before: 1 failure in 50, and 1 in 150.
  • After: 150/150 and then 40/40, at load averages of 20 to 44.
  • Fix broken on purpose: with the cancel check removed from the host's body reader, the test fails.

cargo fmt --all --check passes, and cargo nextest run -p locallibrary passes 2125/2125.

Checklist

  • Tests cover the change
  • For the website: Storybook stories cover any new UI states
  • For locallibrary: apps/locallibrary/CHANGELOG.md has a line under Unreleased, if people using it will notice
  • The READMEs, docs/ and --help still say what the code does (apps/locallibrary/docs/rpc/ too, for a sidecar change)

The test cancelled on a 300 ms timer, which under load fired before the
host had sent the request. Nothing was sent, the server waited in accept
forever, and "the upload stopped" failed after 10 s. The server now
cancels once it has received the first bytes.
@botandbang
botandbang requested a review from bnb as a code owner October 29, 2026 15:41
@github-actions github-actions Bot added locallibrary locallibrary and the loclib-* crates locallibrary: core The core crate, the data model and rekordbox's formats locallibrary: plugins The plugin protocol, its host and the built-in plugins tests Tests, fixtures and test harnesses labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown

Rust coverage

From run 525. Both are held to the thresholds in .cargo/config.toml.

Tests Lines Functions Regions
All 97.52% (81242/83306) 96.68% (12972/13418) 95.83% (178597/186359)
Hegel property tests alone 95.35% (79434/83306) 93.85% (12593/13418) 93.44% (174132/186359)

@botandbang
botandbang merged commit ce36d52 into main Oct 29, 2026
66 checks passed
@botandbang
botandbang deleted the bnb/cancelled-upload branch October 29, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

locallibrary: core The core crate, the data model and rekordbox's formats locallibrary: plugins The plugin protocol, its host and the built-in plugins locallibrary locallibrary and the loclib-* crates tests Tests, fixtures and test harnesses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants