Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion js/net/src/ietf/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,14 @@ export class Frame {

// Defined on every implemented draft, whether or not the header marks the group's end.
if (status === END_OF_TRACK) return new Frame({ endOfTrack: true });
// Allowed even when the header marks the group's end: that bit only lets a FIN imply it,
// and imquic sends both.
if (status === GROUP_END) return new Frame();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

if (flags.hasEnd) {
// Empty frame
if (status === 0) return new Frame({ payload: new Uint8Array(0), timestamp });
} else if (status === 0 || status === GROUP_END) {
} else if (status === 0) {
// TODO status === 0 should be an empty frame, but moq-rs seems to be sending it incorrectly on group end.
return new Frame();
}
Expand Down
28 changes: 28 additions & 0 deletions js/net/src/ietf/subscriber.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,34 @@ test("a clear FIRST_OBJECT at object 0 is the whole group", async () => {
track.close();
});

/**
* The END_OF_GROUP header bit only lets a FIN imply the group's end, so an explicit
* END_OF_GROUP status on the same stream ends the group there rather than failing it.
*/
test("an END_OF_GROUP status on a marked stream finishes the group", async () => {
const { subscriber, track } = await subscribeTrack();

const flags = groupFlags(true);
expect(flags.hasEnd).toBe(true);
// Objects 0..4, then object 5 as a zero-length END_OF_GROUP (0x3) status.
const objects = new Uint8Array([...encodeObjects([0, 0, 0, 0, 0]), 0, 0, 0x3]);
await subscriber.handleGroup(
new GroupMessage({ trackAlias: ALIAS, groupId: 3, subGroupId: 0, publisherPriority: 0, flags }),
new Reader(undefined, objects, VERSION),
);

const group = await track.ordered().nextGroup();
expect(group?.sequence).toBe(3);
if (!group) return;
for (let i = 0; i < 5; i++) {
expect(await group.readString()).toBe("object 0");
}
expect(await group.readFrame()).toBeUndefined();
expect(await group.closed).toBeNull();

track.close();
});

/**
* A clear FIRST_OBJECT whose first ID is not 0 still has a hole at the front, so the
* stream is dropped and the track resumes at the next group.
Expand Down
1 change: 0 additions & 1 deletion quest/m0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ remain and no release waits on them.
- [Serve budget](/quest/m0/serve-budget.md) - a kio task that always has work ready yields after a budget, so a fast publisher can't starve its own QUIC driver
- [Draft-22 media on 0.17](/quest/m0/release-22/README.md) - a 0.17.x with the LOCATION_FILTER and FIRST_OBJECT fixes and moq-noq 1.3.4, before Seattle
- [Capped stream END_OF_GROUP](/quest/m0/ietf-end-of-track-location.md) - a stream capped by the subscription's end Location never claims END_OF_GROUP; moving End of Track's Location is deferred
- [End of Group status](/quest/m0/ietf-end-of-group-status.md) - an End of Group status on a stream whose header already marks the group's end is accepted, so imquic's last object per group arrives
- [FFI publisher stall](/quest/m0/ffi-publisher-stall.md) - every Go and Python publisher cell passes reliably once the serve budget lands, and a cell fails when a connection idles out
- [web-transport releases the qmux fixes](/quest/m0/qmux-credit-upstream.md) - waiting on moq-dev/web-transport#412 and #413 to merge and ship, which qmux credit bumps to
- [qmux credit](/quest/m0/qmux-credit.md) - qmux returns connection credit for dropped and stopped streams and delivers its close frame, on both lines
Expand Down
30 changes: 0 additions & 30 deletions quest/m0/ietf-end-of-group-status.md

This file was deleted.

6 changes: 0 additions & 6 deletions quest/m1/papercuts-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,9 @@ regression test that fails without it:
invalid value warns and falls back to the default, as `parseDelay` and
`parseVisible` already do.

Decided 2026-10-08: [End of Group status](/quest/m0/ietf-end-of-group-status.md)
edits the same status branch in `Frame.decode`; it is m0 and lands first, so
this rebases onto it.

Public API: none. Wire: none.

## Related

- [End of Group status](/quest/m0/ietf-end-of-group-status.md) - the same `Frame.decode` status branch, landing first

- [Rust papercuts](/quest/m1/papercuts-rs.md) - the Rust half of the same audit
- [Audio jitter target](/quest/m1/audio-jitter-target/README.md) - owns the audio ring and its backpressure
51 changes: 43 additions & 8 deletions rs/moq-net/src/ietf/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3178,7 +3178,6 @@ where
/// status for empty objects, and the streamed payload.
struct GroupIngest {
has_extensions: bool,
has_end: bool,
timescale: Option<Timescale>,
version: Version,
prior_object: Option<u64>,
Expand Down Expand Up @@ -3217,7 +3216,6 @@ impl GroupIngest {
) -> Self {
Self {
has_extensions: group.flags.has_extensions,
has_end: group.flags.has_end,
timescale,
version: subscriber.version,
prior_object: None,
Expand Down Expand Up @@ -4264,7 +4262,9 @@ impl GroupIngest {
frame.finish()?;
}
self.phase = IngestPhase::Delta;
} else if status == END_OF_GROUP && !self.has_end {
} else if status == END_OF_GROUP {
// Allowed even when the header marks the group's end: that bit only
// lets a FIN imply it, and imquic sends both.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
self.phase = IngestPhase::Finished(Ended::Group);
} else if status == END_OF_TRACK {
// Defined on every implemented draft, whether or not the header marks
Expand Down Expand Up @@ -7989,10 +7989,10 @@ mod stitch_tests {
}
}

/// Append an END_OF_TRACK object: delta 0, an empty payload, then its status.
fn end_of_track(mut stream: Vec<u8>) -> Vec<u8> {
/// Append a status object such as END_OF_TRACK: delta 0, an empty payload, then its status.
fn end_marker(mut stream: Vec<u8>, status: u64) -> Vec<u8> {
// The id delta, an empty extension block, a zero size, and the status.
for value in [0u64, 0, 0, END_OF_TRACK] {
for value in [0u64, 0, 0, status] {
crate::coding::Encoder::new(&mut stream, VERSION.into())
.varint(value)
.unwrap();
Expand Down Expand Up @@ -8066,7 +8066,10 @@ mod stitch_tests {
/// END_OF_TRACK after a group's last object ends the track right after that group.
#[moq_net_sim::test]
async fn an_end_of_track_after_a_group_ends_the_track_after_it() {
let h = Harness::new(Fill::Done, vec![end_of_track(tail_stream(SEQUENCE, 0, &[b"last"]))]);
let h = Harness::new(
Fill::Done,
vec![end_marker(tail_stream(SEQUENCE, 0, &[b"last"]), END_OF_TRACK)],
);
let mut consumer = h.track.subscribe(None);
let mut stream = h.stream().await;

Expand Down Expand Up @@ -8101,7 +8104,10 @@ mod stitch_tests {
/// and no group is created for it.
#[moq_net_sim::test]
async fn an_end_of_track_at_object_zero_creates_no_group() {
let h = Harness::new(Fill::Done, vec![end_of_track(tail_stream(SEQUENCE, 0, &[]))]);
let h = Harness::new(
Fill::Done,
vec![end_marker(tail_stream(SEQUENCE, 0, &[]), END_OF_TRACK)],
);
let mut stream = h.stream().await;

h.subscriber.clone().recv_group(&mut stream).await.unwrap();
Expand Down Expand Up @@ -8401,6 +8407,35 @@ mod stitch_tests {
assert_eq!(frames[1].1, b"next");
}

/// The END_OF_GROUP header bit only lets a FIN imply the group's end, so an explicit
/// END_OF_GROUP status on the same stream ends the group there rather than failing it.
#[moq_net_sim::test]
async fn an_end_of_group_status_on_a_marked_stream_finishes_the_group() {
use futures::FutureExt;

let payloads: [&[u8]; 5] = [b"o0", b"o1", b"o2", b"o3", b"o4"];
let bytes = end_marker(draft18_subgroup(SEQUENCE, true, 0, &payloads), END_OF_GROUP);
let flags = ietf::GroupFlags::decode(u64::from(bytes[0]), Version::Draft18).unwrap();
assert!(flags.has_end, "the header marks the group's end");

let mut h = Harness::new(Fill::Done, vec![bytes]);
h.subscriber.version = Version::Draft18;
let mut consumer = h.track.subscribe(None);
let mut stream = read_draft18(&h.session).await;

h.subscriber.clone().recv_group(&mut stream).await.expect("the group");

// The stream was read to its end, so everything is already delivered.
let mut group = consumer.recv_group().now_or_never().unwrap().unwrap().unwrap();
assert_eq!(group.sequence, SEQUENCE);
for payload in payloads {
let frame = group.read_frame().now_or_never().unwrap().unwrap().unwrap();
assert_eq!(frame.payload.as_ref(), payload);
}
let end = group.read_frame().now_or_never().expect("the group is closed");
assert!(matches!(end, Ok(None)), "the group is finished, not aborted: {end:?}");
}

/// A clear FIRST_OBJECT whose first ID is not 0 still has a hole at the front, so
/// the stream is dropped and the track resumes at the next group.
#[moq_net_sim::test]
Expand Down
Loading