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
54 changes: 52 additions & 2 deletions js/net/src/ietf/subscriber.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,11 @@ async function subscribeTrack({
version?: IetfVersion;
properties?: Properties;
subscription?: track.Subscription;
} = {}): Promise<{ subscriber: Subscriber; track: track.Subscriber }> {
} = {}): Promise<{
subscriber: Subscriber;
track: track.Subscriber;
pair: ReturnType<typeof createMockTransportPair>;
}> {
const pair = createMockTransportPair(ALPN.DRAFT_18);
const session = new NativeSession(pair.server, version, true);
const subscriber = new Subscriber({ session });
Expand All @@ -748,7 +752,7 @@ async function subscribeTrack({
await peer.writer.u53(SubscribeOk.id);
await new SubscribeOk({ trackAlias: ALIAS, properties }).encode(peer.writer, version);

return { subscriber, track: consumer };
return { subscriber, track: consumer, pair };
}

// A refusal already ended the request: a reset back would tell the publisher we failed. The
Expand Down Expand Up @@ -1519,6 +1523,52 @@ for (const [name, firstObject, bytes] of [
});
}

// The relay forwards a withdrawn route's END_OF_TRACK just as the viewer's own unsubscribe
// closes the track, so the marker lands on a track that already ended. The track is gone, not
// the publisher wrong, so the session stays up for the route that replaces it.
test("an END_OF_TRACK after the track closed locally leaves the session open", async () => {
const { subscriber, track, pair } = await subscribeTrack();
const close = spyOn(pair.server, "close");
const opened = Promise.withResolvers<void>();
const open = Tail.prototype.open;
const opening = spyOn(Tail.prototype, "open").mockImplementation(function (this: Tail, sequence) {
opened.resolve();
return open.call(this, sequence);
});
Comment thread
kixelated marked this conversation as resolved.
Resolved
const ended = Promise.withResolvers<void>();
// Restored even when an assertion or a wait below fails, so no other test runs through the spies.
onTestFinished(() => {
ended.resolve();
opening.mockRestore();
close.mockRestore();
});
// A standalone END_OF_TRACK at object 0, whose stream has not ended yet.
const readable = new ReadableStream<Uint8Array>({
start(controller) {
controller.enqueue(new Uint8Array([0, 0, 4]));
void ended.promise.then(() => controller.close());
},
});
const reader = new Reader(readable, undefined, VERSION);
const handled = subscriber.handleGroup(
new GroupMessage({
trackAlias: ALIAS,
groupId: 3n,
subGroupId: 0n,
publisherPriority: 0,
flags: groupFlags(true),
}),
reader,
);
await opened.promise;
// Let the handler decode the marker and wait for its stream to end.
for (let i = 0; i < 10; i++) await yieldNow();
track.close();
await handled;

expect(close).not.toHaveBeenCalled();
});

test("every object in a chunk reaches the reader before it wakes", async () => {
const { subscriber, track } = await subscribeTrack();

Expand Down
4 changes: 4 additions & 0 deletions js/net/src/ietf/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,10 @@ export class Subscriber {
// the track ends with it, and at object 0 it ends before it.
if (producer && frame.idDelta !== 0) throw new ObjectIdGap(frame.idDelta);
await last();
// Our own unsubscribe can release the track while its marker is in flight. A
// released track has no end left to declare, and the publisher did nothing wrong,
// so refusing it would close the session and every other subscription with it.
if (hooks.trackReleased(track).peek() !== undefined && !hooks.trackFinished(track)) return;
const end = { group: group.groupId, frame: nextObject + frame.idDelta };
producer?.finish();
try {
Expand Down
41 changes: 37 additions & 4 deletions quest/m0/interop-green/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ so it only needs to stay green.

## Waiting

- moq-dev/moq: the next scheduled Interop run on `main` passes, once the
[resumed-audio fix](https://github.com/moq-dev/moq/pull/8635) lands
([moq-dev/moq#8572](https://github.com/moq-dev/moq/pull/8572), the max-age
fix, merged 2026-11-12). Check
- moq-dev/moq: the next scheduled Interop run on `main` passes, now that
[moq-dev/moq#8572](https://github.com/moq-dev/moq/pull/8572) (max age,
2026-11-12) and [moq-dev/moq#8635](https://github.com/moq-dev/moq/pull/8635)
(resumed audio, 2026-11-14) have landed. Check
with `gh run list --repo moq-dev/moq --workflow interop.yml --event schedule`,
then the run's STEPS summary. The JS route port that [moq-dev/moq#8290](https://github.com/moq-dev/moq/pull/8290)
waited on landed in [moq-dev/moq#8443](https://github.com/moq-dev/moq/pull/8443),
Expand Down Expand Up @@ -190,5 +190,38 @@ Scheduled run

The 11-11 run, before #8507, passed all three steps.

Scheduled runs
[43457651679](https://github.com/moq-dev/moq/actions/runs/43457651679)
(2026-11-13, at c748c0d47) and
[43606836954](https://github.com/moq-dev/moq/actions/runs/43606836954)
(2026-11-14, at bd617cc1e) show the media step moving on, and the matrix going green:

- 11-13 Media: the pause case's audio after resume, fixed by
[moq-dev/moq#8635](https://github.com/moq-dev/moq/pull/8635), merged
2026-11-14 after that run.
- 11-13 Interop (full matrix) and Interop (moq-transport): `js -> cpp`,
`js -> python`, and `js -> rust` each failed once with `audio gap`, a
different cell per matrix, with no repeat on 11-14, where both steps passed.
This is the intermittent audio gap
[moq-dev/moq#8633](https://github.com/moq-dev/moq/pull/8633) and
[moq-dev/moq#8611](https://github.com/moq-dev/moq/pull/8611) track, not a
new cause.
- 11-14 Media: only `live incumbent fallback plays` on `moq-transport-22`
failed. The viewer's session closed with `invalid END_OF_TRACK: track is
closed` and reconnected, so the fallback took more than its 1039 ms bound.
The JS subscriber refused the END_OF_TRACK of a withdrawn route after its own
unsubscribe had released the track, and a protocol violation closes the whole
session.
[moq-dev/moq#8769](https://github.com/moq-dev/moq/pull/8769) tolerates the marker on a released track.
That is not the whole case: since [moq-dev/moq#8443](https://github.com/moq-dev/moq/pull/8443)
dropped the Chromium quarantine, `just test media --media-cases replacement`
at `ce616b52c` failed 4 of 14 local runs (host at load 50), as `live incumbent
fallback plays` on `moq-lite-06` and `moq-transport-22` or the fallback audio
tone, with no END_OF_TRACK violation in the log kept. Both failing logs show
`skipping missing groups` on the audio track before the stall, so the audio
stalls past the 1039 ms bound after the route falls back. Still open:
root-cause that hole before the next scheduled run, or quarantine `replacement`
on Chromium again, as on Firefox, until it is.

Public API: none. Wire: none.