From 670045ccfcfa96baba5b19ab0246327420504a82 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 20:01:18 -0800 Subject: [PATCH 1/2] chore(quest): claim quest/m2/ts-follow-retry.md Quest-Claim: 359179191b719553 From 796de523a3a3dd6fa2365d864d4c163468d497c6 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 20:42:27 -0800 Subject: [PATCH 2/2] fix(moq-mux): the TS follower judges a publisher leaving by its error's retry answer Co-Authored-By: Claude Sonnet 5.5 --- quest/m2/ts-follow-retry.md | 31 ---------------------- rs/moq-mux/src/container/ts/export_test.rs | 17 +++++++----- rs/moq-mux/src/container/ts/follower.rs | 28 ++++++++----------- 3 files changed, 22 insertions(+), 54 deletions(-) delete mode 100644 quest/m2/ts-follow-retry.md diff --git a/quest/m2/ts-follow-retry.md b/quest/m2/ts-follow-retry.md deleted file mode 100644 index 4279a5478ed..00000000000 --- a/quest/m2/ts-follow-retry.md +++ /dev/null @@ -1,31 +0,0 @@ -# [S] The TS follower judges a publisher leaving by its error's retry answer - -## Goal - -`moq_mux::container::ts::follower::left` asks `moq_net::Error::retry` -whether the publisher left, instead of matching `moq_net::Error` variants, -so the TS export and moq-gst's `moqsrc` agree on what ends a run. - -## Plan - -`left` (`rs/moq-mux/src/container/ts/follower.rs`) matches `Unroutable`, -`Stream(Unroutable | Session(_))`, `Session(_)`, `Transport(_)`, -`IdleTimeout`, and `Remote(_)`. `retry() != Retry::Never` differs on two -groups, each pinned by a test in `export_test.rs`: - -- `Cancel`, `Closed`, `GoingAway`, `Dropped`, and the stream codes - `Internal`, `Cancel`, `GoingAway`, and `ControlTimeout` are a failed - delivery to `retry` but the export's own failure to `left` - (`a_follower_fails_at_once_on_its_own_failure`). -- `Remote(_)`, a code moq-lite does not assign, is a verdict to `retry` but a - publisher leaving to `left` (`a_follower_waits_out_the_follow_on_a_lost_route`). - Over moq-transport a relay's lost upstream and a publisher's own failure both - end with PUBLISH_DONE INTERNAL_ERROR (`Remote(0)`), which no reader can tell - apart, so `retry` cannot answer for it. - -Settled (maintainer, 2026-11-16, -[#8955](https://github.com/moq-dev/moq/pull/8955#issuecomment-6930707585)): -adopt `retry`, so a cancel, GOAWAY, or INTERNAL_ERROR reset counts as the -publisher leaving, as `moqsrc` does. Rejected: counting it as the export's -own failure. `left` keeps `Remote(_)` as the one case it still matches, as -moq-transport's lost route. diff --git a/rs/moq-mux/src/container/ts/export_test.rs b/rs/moq-mux/src/container/ts/export_test.rs index f662d5dd779..44c72b61b98 100644 --- a/rs/moq-mux/src/container/ts/export_test.rs +++ b/rs/moq-mux/src/container/ts/export_test.rs @@ -9951,9 +9951,9 @@ fn finish((broadcast, mut catalog): (moq_net::origin::Route, crate::catalog::Pro #[tokio::test(start_paused = true)] async fn a_follower_fails_at_once_on_its_own_failure() { let causes = [ - moq_net::Error::Cancel, - moq_net::Error::Stream(moq_net::StreamError::Internal), moq_net::Error::MalformedTrack, + moq_net::Error::NotFound, + moq_net::Error::Stream(moq_net::StreamError::MalformedTrack), ]; for cause in causes { let origin = crate::source::produce_origin(); @@ -9978,16 +9978,21 @@ async fn a_follower_fails_at_once_on_its_own_failure() { } } -/// A track that lost its route, or whose session ended, says the publisher left even with the -/// broadcast still announced: the follower waits out the follow for a return, then fails with -/// that cause. moq-transport's PUBLISH_DONE has no code for a lost route, so a relay's copy -/// reads there as an unregistered one. +/// A track that failed to deliver, as `retry` answers, says the publisher left even with the +/// broadcast still announced: a lost route, an ended session, a cancel, or a going away. The +/// follower waits out the follow for a return, then fails with that cause. moq-transport's +/// PUBLISH_DONE has no code for a lost route, so a relay's copy reads there as an unregistered +/// one. #[tokio::test(start_paused = true)] async fn a_follower_waits_out_the_follow_on_a_lost_route() { let causes = [ moq_net::Error::Unroutable, moq_net::Error::Stream(moq_net::StreamError::Unroutable), moq_net::Error::Session(moq_net::SessionError::Cancel), + moq_net::Error::Cancel, + moq_net::Error::GoingAway, + moq_net::Error::Stream(moq_net::StreamError::Internal), + moq_net::Error::Stream(moq_net::StreamError::GoingAway), moq_net::Error::Remote(0), ]; for cause in causes { diff --git a/rs/moq-mux/src/container/ts/follower.rs b/rs/moq-mux/src/container/ts/follower.rs index 30bf2c1a9f8..341c505b30e 100644 --- a/rs/moq-mux/src/container/ts/follower.rs +++ b/rs/moq-mux/src/container/ts/follower.rs @@ -68,11 +68,11 @@ enum State { /// switches the program to it at once. Subscriptions are sticky, so without stitching a /// replaced publisher that stays up keeps the export until it ends. /// -/// A track failure is followed only when its cause says the publisher left: the route serving -/// it was lost (`Unroutable`, which a moq-lite relay resets a copy with once its upstream -/// session ends), the session carrying it ended, or a moq-transport peer ended it with a code -/// it does not register, since PUBLISH_DONE has none for a lost route. Any other failure is -/// the export's own and fails here at once. +/// A track failure is followed only when its cause says the publisher left: the source failed +/// to deliver, as [`moq_net::Error::retry`] answers (a lost route, an ended session, a cancel, +/// or a going away), or a moq-transport peer ended it with a code it does not register, since +/// PUBLISH_DONE has none for a lost route. Any other failure is the export's own and fails +/// here at once. /// /// An instance that comes back is awaited until its catalog serves a first snapshot, with no /// deadline but its own end. A return that refuses its catalog waits for the next change, and @@ -418,20 +418,14 @@ impl Follower { } } -/// Whether a failure says the publisher left rather than the export failing: the route serving -/// the broadcast was lost, the session carrying it ended, or a moq-transport peer named no cause. +/// Whether a failure says the publisher left rather than the export failing: the source failed +/// to deliver (see [`moq_net::Error::retry`]), or a moq-transport peer named no cause. +/// +/// moq-transport's PUBLISH_DONE has no code for a lost route, so a relay's lost upstream and a +/// publisher's own failure both end with an unregistered one, which `retry` cannot answer for. pub(super) fn left(err: &crate::Error) -> bool { let (crate::Error::Moq(err) | crate::Error::Hang(hang::Error::Moq(err))) = err else { return false; }; - use moq_net::{Error, StreamError}; - matches!( - err, - Error::Unroutable - | Error::Stream(StreamError::Unroutable | StreamError::Session(_)) - | Error::Session(_) - | Error::Transport(_) - | Error::IdleTimeout - | Error::Remote(_) - ) + err.retry() != moq_net::Retry::Never || matches!(err, moq_net::Error::Remote(_)) }