diff --git a/quest/m0/test-flakes-3/py-socket-abort.md b/quest/m0/test-flakes-3/py-socket-abort.md deleted file mode 100644 index 8e96b579410..00000000000 --- a/quest/m0/test-flakes-3/py-socket-abort.md +++ /dev/null @@ -1,32 +0,0 @@ -# [S] A closed endpoint ends its streams as Closed, never unroutable - -## Goal - -`py/moq-rs/tests/test_socket.py::test_abort_and_endpoint_close_are_errors` -passes every run. - -## Plan - -Found 2026-11-15 by `just check` on -[moq-dev/moq#8838](https://github.com/moq-dev/moq/pull/8838), whose change does -not reach a local origin's socket. Run alone, it fails about 1 run in 3 at line -90: after `a.close()`, `server.consumer.read_frame()` raises -`moq.Error.Protocol: unroutable` instead of `moq.Error.Closed`, so closing an -endpoint races its route's withdrawal against its streams' ending. Fix the -endpoint at the cause, as the epic's rules ask. - -First check whether it still reproduces after -[moq-dev/moq#8825](https://github.com/moq-dev/moq/pull/8825), which makes every -ending of a socket endpoint run its cleanup and likely fixes it: run the test -alone in a loop on a base that includes it. If it no longer fails, delete this -quest; if it does, the cause lies elsewhere. - -Decided 2026-11-16 (maintainer, /quest-plan of the pre-cut audit): socket -endpoints leave moq for Kixel, and -[their removal](/quest/m2/sockets/remove.md) deletes this test with the -Python wrapper. So do not fix the endpoint here. If the test still flakes -before the removal lands, skip it with the removal quest as its owner and -delete this quest; the removal deletes this quest otherwise. Kixel's port -inherits the race, which goes in that PR's follow-ups for Kixel's tree. - -Public API: none. Wire: none. diff --git a/quest/m2/sockets/remove.md b/quest/m2/sockets/remove.md index a078b6f91c6..19b8489c707 100644 --- a/quest/m2/sockets/remove.md +++ b/quest/m2/sockets/remove.md @@ -78,8 +78,6 @@ For the PR: must already be off it. - Record the PR's parent commit in the PR body: it is the reference Kixel ports from. -- If [the closed-endpoint flake](/quest/m0/test-flakes-3/py-socket-abort.md) - is still open, delete it here: its test leaves. - Run `just test interop --all` (moq-ffi changes) and `just api-diff`. Public API: breaking for `main`-only API in every language; nothing on diff --git a/rs/moq-net/src/model/front.rs b/rs/moq-net/src/model/front.rs index 122db890cc5..a8e729d74a3 100644 --- a/rs/moq-net/src/model/front.rs +++ b/rs/moq-net/src/model/front.rs @@ -185,8 +185,9 @@ struct Track { /// The most recent refusal, reported when every source has refused, with the Retry /// Interval an upstream refusal asked for. refusal: Option<(Error, Option)>, - /// Why the serving copy died mid-serve, while its re-splice is asked for. A refusal of - /// that re-splice reports this instead: the source closing is what ended the track. + /// Why the serving copy died mid-serve, or what a closing source answered, while a + /// re-splice is awaited. A refusal of that re-splice, or the front ending first, reports + /// this instead: the source closing is what ended the track. lost: Option, /// Whether anyone reads the track: a copy is only spliced in for a reader. wanted: bool, @@ -276,8 +277,8 @@ impl Front { self.serving.map(|(source, _)| source) } - /// Why `track`'s serving copy died mid-serve, while its re-splice is still asked for. - /// A track the front ends meanwhile ends with this rather than the front's end. + /// Why `track`'s serving copy died, while its re-splice is still awaited. A track the + /// front ends meanwhile ends with this rather than the front's end. pub(super) fn lost(&self, track: &str) -> Option { self.tracks.get(track)?.lost.clone() } @@ -644,9 +645,11 @@ impl Front { let serving = self.serving.is_some_and(|(serving, _)| serving == source); let track = self.tracks.get_mut(&name).expect("refusing a known track"); track.state = TrackState::Idle; - // A closing source's answer is not a verdict: it is on its way out and - // its replacement is asked afresh. + // A closing source's answer is not a verdict: it is on its way out and its + // replacement is asked afresh. It is still what ended the track if nothing replaces + // the source, unless an earlier loss did. if closing { + track.lost.get_or_insert(refusal.0); return; } // A route that lost the content says nothing of the track: wait for another of its @@ -1258,6 +1261,79 @@ mod tests { ); } + /// A copy reset before delivering, seen only once its source began closing, such as a + /// session of a closing socket endpoint, is no refusal, yet ends the track with the reset + /// rather than `Unroutable` when nothing replaces the source, or when its replacement + /// refuses. The driver reports it as the copy's end once spliced, or as the answer to + /// its query when the reset came before the metadata was read. + #[test] + fn a_closing_source_reset_reports_the_loss() { + let reset = || Error::from(crate::StreamError::Session(crate::SessionError::Cancel)); + let ended = || { + let mut front = serving(local(1), 100); + let actions = front.step(Event::TrackEnded { + track: name("video"), + source: 100, + closing: true, + result: Err(reset()), + delivered: false, + }); + (front, actions) + }; + let answered = || { + let mut front = querying(local(1), 100); + let actions = front.step(Event::TrackInfo { + track: name("video"), + source: 100, + closing: true, + result: Err(reset()), + retry: None, + }); + (front, actions) + }; + for (mut front, actions) in [ended(), answered()] { + assert_actions(actions, &[]); + assert!(front.tracks[&name("video")].refused.is_empty()); + front.step(Event::SourceClosed { source: 100 }); + + let mut replaced = front.clone(); + replaced.step(Event::Selected { + best: Some(local(2)), + serving_closing: false, + }); + replaced.step(Event::Resolved { + route: 2, + result: Ok(200), + }); + assert_actions( + replaced.step(Event::TrackInfo { + track: name("video"), + source: 200, + closing: false, + result: Err(Error::NotFound), + retry: None, + }), + &[Action::Abort { + track: name("video"), + err: reset(), + retry: None, + }], + ); + + assert_actions( + front.step(Event::Selected { + best: None, + serving_closing: false, + }), + &[Action::End { err: Error::Unroutable }], + ); + assert_eq!( + front.lost("video").map(|err| err.to_string()), + Some(reset().to_string()) + ); + } + } + /// A source that loses a copy mid-serve and then refuses its re-splice, such as a /// closing socket endpoint, ends the track with the loss, not the refusal. #[test]