Skip to content

fix(moq-ffi): unblock deadlocking dynamic_track_request tests#1712

Merged
kixelated merged 1 commit into
devfrom
claude/fervent-swartz-8c918f
Jun 13, 2026
Merged

fix(moq-ffi): unblock deadlocking dynamic_track_request tests#1712
kixelated merged 1 commit into
devfrom
claude/fervent-swartz-8c918f

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Summary

Two moq-ffi tests deadlocked (hung forever): dynamic_track_request and dynamic_track_request_can_abort in rs/moq-ffi/src/test.rs.

Root cause: the tests called consumer.subscribe_track("...").await before 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 via requested_track(). But requested_track() only runs on the line after the one the test is blocked on, so it's never reached. Classic single-task deadlock. The sibling media_track_activity_and_name doesn't hang because it publishes the track first, so subscribe_track finds an existing producer and returns immediately.

The await itself is correct: the pending-until-accepted contract is intentional (see the subscribe_pending! macro in rs/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 with tokio::join!, so the producer accepts the request while the consumer is still awaiting acceptance. The requested_track() side keeps its existing TIMEOUT wrapper, so a real regression fails fast instead of hanging.

Why this was never caught

b1580b48 made subscribe_track async (correct) but moq-ffi's tests have never actually run in CI: just rs ci's cargo test --workspace --all-features died 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)

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
kixelated enabled auto-merge (squash) June 13, 2026 21:46
@kixelated
kixelated disabled auto-merge June 13, 2026 22:05
@kixelated
kixelated merged commit ff85227 into dev Jun 13, 2026
1 check failed
@kixelated
kixelated deleted the claude/fervent-swartz-8c918f branch June 13, 2026 22:05
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.

1 participant