fix(moq-ffi): unblock deadlocking dynamic_track_request tests#1712
Merged
Conversation
dynamic_track_request and dynamic_track_request_can_abort awaited consumer.subscribe_track() to completion before reaching dynamic.requested_track() on the next line. For a not-yet-published (dynamic) track, subscribe_track().await stays pending until the producer accepts the request, which only happens once requested_track() runs. Single-task deadlock: the test could never reach the line that unblocks the line it was waiting on. Drive both sides concurrently with tokio::join! so the producer accepts the request while the consumer is still awaiting acceptance. The requested_track() side keeps its TIMEOUT wrapper so a real regression fails fast instead of hanging. This is pre-existing debt unrelated to moq-video: b1580b4 made subscribe_track async (correct, the pending-until-accepted contract is intentional) but the tests were never caught because moq-ffi's tests never ran in CI. `just rs ci` died at the NVENC compile before reaching the test phase until #1704 fixed that pipeline. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
kixelated
enabled auto-merge (squash)
June 13, 2026 21:46
kixelated
disabled auto-merge
June 13, 2026 22:05
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
Two moq-ffi tests deadlocked (hung forever):
dynamic_track_requestanddynamic_track_request_can_abortinrs/moq-ffi/src/test.rs.Root cause: the tests called
consumer.subscribe_track("...").awaitbeforedynamic.requested_track()on the next line. For a not-yet-published (dynamic) track,subscribe_track().awaitstays pending until the producer accepts the request viarequested_track(). Butrequested_track()only runs on the line after the one the test is blocked on, so it's never reached. Classic single-task deadlock. The siblingmedia_track_activity_and_namedoesn't hang because it publishes the track first, sosubscribe_trackfinds an existing producer and returns immediately.The
awaititself is correct: the pending-until-accepted contract is intentional (see thesubscribe_pending!macro inrs/moq-net/src/model/broadcast.rs, which asserts subscribe stays pending until the request is accepted). The bug was the test driving the two sides sequentially.Fix
Drive the consumer subscribe and the producer
requested_track()concurrently withtokio::join!, so the producer accepts the request while the consumer is still awaiting acceptance. Therequested_track()side keeps its existingTIMEOUTwrapper, so a real regression fails fast instead of hanging.Why this was never caught
b1580b48madesubscribe_trackasync (correct) but moq-ffi's tests have never actually run in CI:just rs ci'scargo test --workspace --all-featuresdied at the NVENC compile (since #1691) before reaching the test phase. #1704 fixed that pipeline, so the tests now run — and hung. This is pre-existing moq-ffi debt, unrelated to the moq-video work.Test plan
nix develop --command cargo test -p moq-ffi— 20 passed, 0 failed (the two previously-hanging tests now finish in 0.42s total)nix develop --command cargo test --workspace --all-features --exclude moq-video— exit 0, whole suite green, no hang(Written by Claude)