Skip to content

test: keep what's on its way at a cancel from failing the upload harnesses - #460

Merged
botandbang merged 2 commits into
mainfrom
bnb/youtube-cancel-flake
Nov 5, 2026
Merged

botandbang merged 2 commits into
mainfrom
bnb/youtube-cancel-flake

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

Fixes a flake in plugins/youtube's prop_a_cancel_stops_the_publish_wherever_it_is, from #437, which failed unrelated PRs: #447 (Linux), #453 (Hegel coverage) and #454 (macOS). The plugin is right and the test harness was wrong.

The host answers a chunk, then cancels. The plugin can read the answer and send the next chunk before the cancel reaches it, which the test expects (n + 1..=n + 2 requests). That chunk then races the test's teardown in two ways:

  • Session::stop read the fake host's record, then closed the connection and joined the answering thread. A chunk arriving after that read found an empty record, so a chunk goes on from where YouTube got to failed with left 65536, right 0, on the answering thread. The test thread then failed at answering.join(), and at received() on the poisoned mutex.
  • The fake host opened the chunk's file, and the cancelled plugin may already have removed the video it made in its scratch folder. A real host doesn't read it: the plugin cancels its call on the way out, and that call is answered cancelled.

Changed

  • stop in the archive, mixcloud, plyr, soundcloud and youtube harnesses reads the record after the answering thread has finished, so it holds everything the plugin sent. All five had this order. The doc comments on three said the record was complete because the plugin sends nothing once it has answered; that's true of the plugin, but not of what's already on its way. Their cancel tests already allow the one extra request, so no assertion changes.
  • The youtube fake host answers a call cancelled once it has cancelled the publish, and still counts it.

Added and removed

Nothing.

Both races were reproduced on demand by delaying the fake host between answering and cancelling, and before it handled a request: the first panicked at youtube.rs:166, and with only that fixed the second panicked at :172. With both fixed, the test passed 15 of 15 under the same delays, and all five crates' tests passed 3 of 3. Without the delays the test passed 40 of 40 and all five crates' tests 5 of 5.

…esses

A publish cancelled with a request on its way failed the test around it, not the plugin. stop()
read the fake host's record before the answering thread had finished, so that request landed on
an empty one, and the YouTube host opened a video the cancelled plugin had already removed.
@botandbang
botandbang requested a review from bnb as a code owner November 5, 2026 17:39
@botandbang botandbang added the all-os Run the macOS and Windows checks on this pull request label Nov 5, 2026
@github-actions github-actions Bot added locallibrary locallibrary and the loclib-* crates locallibrary: plugins The plugin protocol, its host and the built-in plugins locallibrary: publishing The Atmosphere account, and the sets and profile published to it tests Tests, fixtures and test harnesses labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Rust coverage

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

Tests Lines Functions Regions
All 97.68% (87985/90077) 97.07% (14314/14746) 96.07% (194488/202448)
Hegel property tests alone 96.1% (86562/90077) 95.38% (14065/14746) 94.37% (191041/202448)

@botandbang
botandbang added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit aa54cc6 Nov 5, 2026
33 checks passed
@botandbang
botandbang deleted the bnb/youtube-cancel-flake branch November 5, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

all-os Run the macOS and Windows checks on this pull request locallibrary: plugins The plugin protocol, its host and the built-in plugins locallibrary: publishing The Atmosphere account, and the sets and profile published to it 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