From e1a008d0778592fa4e6d285c2abf269f08800d85 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 23:07:24 -0800 Subject: [PATCH 1/5] chore(quest): claim quest/m0/test-flakes-2/js-subscribe-fixture.md Quest-Claim: 5a7667f9b4147c0f From 39c9c07c88e72e41e52bf891f067acd26b013b58 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 23:12:35 -0800 Subject: [PATCH 2/5] test(net): decode complete subscribe requests in the fixture Co-Authored-By: GPT-6.1 Sol --- quest/m0/test-flakes-2/README.md | 1 - .../m0/test-flakes-2/js-subscribe-fixture.md | 31 ------------------- 2 files changed, 32 deletions(-) delete mode 100644 quest/m0/test-flakes-2/js-subscribe-fixture.md diff --git a/quest/m0/test-flakes-2/README.md b/quest/m0/test-flakes-2/README.md index 875eb5e3ece..af40dd329c6 100644 --- a/quest/m0/test-flakes-2/README.md +++ b/quest/m0/test-flakes-2/README.md @@ -96,7 +96,6 @@ Public API: none. Wire: none. - [moq-archive's cross-backend recording test survives load](/quest/m0/test-flakes-2/archive-backends-identical.md) - `recordings_are_byte_identical_on_every_backend` stops splitting S3's video objects differently - [moq-ffi's panicked-origin supervision test survives load](/quest/m0/test-flakes-2/ffi-origin-panic.md) - a read the origin driver's panic ends always reports `MoqError::Task` - [The scheduled macOS WebSocket version test completes reliably](/quest/m0/test-flakes-2/macos-websocket.md) - fix the scheduled timeout while preserving newest-version negotiation assertions -- [@moq/net's lite subscribe tests wait for the whole request](/quest/m0/test-flakes-2/js-subscribe-fixture.md) - the three lite subscribe-with-track cases pass under forced yields - [Concurrent PulseAudio harness runs don't share a D-Bus name](/quest/m0/test-flakes-2/pulse-dbus.md) - parallel media runs no longer collide on `org.PulseAudio1` - [@moq/net's uni-stream flood test survives reruns](/quest/m0/test-flakes-2/js-stream-flood.md) - "a flood of uni streams yields" passes under `--rerun-each` and load - [The JS receive-credit qmux test never completes an oversized frame](/quest/m0/test-flakes-2/receive-credit-qmux.md) - `javascript_partial_frame_gives_way_qmux` stops completing a frame larger than the window on moq-transport-18 diff --git a/quest/m0/test-flakes-2/js-subscribe-fixture.md b/quest/m0/test-flakes-2/js-subscribe-fixture.md deleted file mode 100644 index 15a883993d5..00000000000 --- a/quest/m0/test-flakes-2/js-subscribe-fixture.md +++ /dev/null @@ -1,31 +0,0 @@ -# [XS] @moq/net's lite subscribe tests wait for the whole request - -## Goal - -The three `lite %s: a subscribe goes out with its track` cases (lite-05, -06, and 07) in `js/net/src/lite/subscriber.test.ts` pass when every budget -poll is forced to yield. They decode the SUBSCRIBE only after the request -has been fully written. - -## Plan - -Decided 2026-11-03 (maintainer, /quest-plan of the follow-ups from -[moq-dev/moq#7663](https://github.com/moq-dev/moq/pull/7663)): milestone m0, -a child of the test-flakes epic. #7663 fixes the announce harness only and -leaves these tests alone. - -- The test (`subscriber.test.ts:1289`) waits on `(await - opened(1)).writing`, which resolves on the first written chunk. It then - decodes `streams[1].written`. The `fakeSession` fixture (`:1015`) copies - the bytes after one host turn, so under forced yields the SUBSCRIBE can - still be partial. -- Wait on a signal that the request is complete, such as a full-message - promise from the fixture, then decode. Don't wait on the subscriber reading - its response, as #7663 does for the announce harness: on lite-05 and later - the subscriber reads it only after TRACK_INFO, which the test sends after - decoding SUBSCRIBE. -- Verify under forced yields (#7663 shows how to force them) and at normal - speed. Check `fakeSession`'s other users for the same partial-write - wait. - -Public API: none. Wire: none. From e8ab555e255b98828c2ce0aa39ba796a4f4adaa7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 23:12:55 -0800 Subject: [PATCH 3/5] test(net): stream fake session writes into request decoding Co-Authored-By: GPT-6.1 Sol --- js/net/src/lite/subscriber.test.ts | 103 +++++++++++++++++------------ 1 file changed, 59 insertions(+), 44 deletions(-) diff --git a/js/net/src/lite/subscriber.test.ts b/js/net/src/lite/subscriber.test.ts index 962e19cdb55..a652a6be151 100644 --- a/js/net/src/lite/subscriber.test.ts +++ b/js/net/src/lite/subscriber.test.ts @@ -1008,6 +1008,8 @@ test("an unknown announce type between starts keeps the stream", async () => { interface FakeStream { inbound: ReadableStreamDefaultController; + // The subscriber's writes as they arrive, so a decoder can wait for a whole message. + outbound: ReadableStream; // Resolves once the subscriber waits on a read the test has not answered. reading: Promise; aborted: Promise; @@ -1038,6 +1040,8 @@ function fakeSession(park: number[] = [], stall: number[] = []) { close: (info?: WebTransportCloseInfo) => void closes.push(info), createBidirectionalStream: () => { let inbound!: ReadableStreamDefaultController; + let sent!: ReadableStreamDefaultController; + const outbound = new ReadableStream({ start: (controller) => (sent = controller) }); let onRead!: () => void; let onAbort!: (reason: unknown) => void; let onFinish!: () => void; @@ -1066,7 +1070,9 @@ function fakeSession(park: number[] = [], stall: number[] = []) { stopped.refused(); return Promise.reject(stopped.reason); } - written.push(new Uint8Array(chunk)); + const copy = new Uint8Array(chunk); + written.push(copy); + sent.enqueue(copy); onWrite(); return new Promise((resolve) => { if (stalled) return; @@ -1080,8 +1086,14 @@ function fakeSession(park: number[] = [], stall: number[] = []) { channel.port2.postMessage(null); }); }, - close: () => onFinish(), - abort: (reason) => void onAbort(reason), + close: () => { + sent.close(); + onFinish(); + }, + abort: (reason) => { + sent.error(reason); + onAbort(reason); + }, }); const opened = new Promise((resolve) => (release = () => resolve({ readable, writable }))); if (!park.includes(streams.length)) release(); @@ -1089,7 +1101,7 @@ function fakeSession(park: number[] = [], stall: number[] = []) { new Promise((refused) => { stopped = { reason, refused }; }); - streams.push({ inbound, reading, aborted, finished, writing, written, release, stop }); + streams.push({ inbound, outbound, reading, aborted, finished, writing, written, release, stop }); count.set(streams.length); return opened; }, @@ -1299,47 +1311,50 @@ test("a lite subscribe whose SUBSCRIBE write stalls past the deadline closes its // On lite-05 and later a SUBSCRIBE goes out beside its TRACK, before the TRACK_INFO, and accepting // the info sends no SUBSCRIBE_UPDATE even when the publisher keeps groups for less than the // subscriber waits. -test.each([Version.DRAFT_05, Version.DRAFT_06, Version.DRAFT_07])( - "lite %s: a subscribe goes out with its track", - async (version) => { - const { quic, streams, opened } = fakeSession(); - const subscriber = new Subscriber(quic, version, HopSchema.parse(1n)); - const track = subscriber - .consume(Path.from("room")) - .track("video") - .subscribe({ priority: 3, delay: { max: Milli(10_000) } }); - try { - await opened(0); - await streams[0].reading; - await (await opened(1)).writing; - const sent = new Reader(undefined, new Uint8Array(Buffer.concat(streams[0].written)), version); - expect(await sent.u53()).toBe(StreamId.Track); - await drainReactions(); - const wire = () => new Reader(undefined, new Uint8Array(Buffer.concat(streams[1].written)), version); - let subscribe = wire(); - expect(await subscribe.u53()).toBe(StreamId.Subscribe); - const msg = await Subscribe.decode(subscribe, version); - expect([msg.id, msg.track, msg.priority, msg.maxDelay]).toEqual([0n, "video", 3, 10_000]); +test.each( + [Version.DRAFT_05, Version.DRAFT_06, Version.DRAFT_07].flatMap((version) => + [false, true].map((forced) => [version, forced] as const), + ), +)("lite %s: a subscribe goes out with its track (forced yields: %s)", async (version, forced) => { + const yielding = forced ? spyOn(Budget.prototype, "poll").mockImplementation(() => yieldNow()) : undefined; + const { quic, streams, opened } = fakeSession(); + const subscriber = new Subscriber(quic, version, HopSchema.parse(1n)); + const track = subscriber + .consume(Path.from("room")) + .track("video") + .subscribe({ priority: 3, delay: { max: Milli(10_000) } }); + try { + await opened(0); + await streams[0].reading; + const sent = new Reader(undefined, new Uint8Array(Buffer.concat(streams[0].written)), version); + expect(await sent.u53()).toBe(StreamId.Track); + const request = await opened(1); + const subscribe = new Reader(request.outbound, undefined, version); + expect(await subscribe.u53()).toBe(StreamId.Subscribe); + // Reading the request waits for its body without needing TRACK_INFO first. + const msg = await Subscribe.decode(subscribe, version); + expect([msg.id, msg.track, msg.priority, msg.maxDelay]).toEqual([0n, "video", 3, 10_000]); - const chunks: Uint8Array[] = []; - const writer = new Writer( - new WritableStream({ write: (chunk) => void chunks.push(new Uint8Array(chunk)) }), - version, - ); - await new TrackInfo({ timescale: 1000, maxAge: 1000 }).encode(writer, version); - for (const chunk of chunks) streams[0].inbound.enqueue(chunk); - await track.info(); - await drainReactions(); - subscribe = wire(); - await subscribe.u53(); - await Subscribe.decode(subscribe, version); - expect(await subscribe.done()).toBe(true); - } finally { - track.close(); - subscriber.close(); - } - }, -); + const chunks: Uint8Array[] = []; + const writer = new Writer( + new WritableStream({ write: (chunk) => void chunks.push(new Uint8Array(chunk)) }), + version, + ); + await new TrackInfo({ timescale: 1000, maxAge: 1000 }).encode(writer, version); + for (const chunk of chunks) streams[0].inbound.enqueue(chunk); + await track.info(); + await request.reading; + await drainReactions(); + const wire = new Reader(undefined, new Uint8Array(Buffer.concat(request.written)), version); + await wire.u53(); + await Subscribe.decode(wire, version); + expect(await wire.done()).toBe(true); + } finally { + track.close(); + subscriber.close(); + yielding?.mockRestore(); + } +}); // A GROUP that beats its subscription's TRACK_INFO waits unread for it, then is read with it. test("a group that beats its track info waits for it", async () => { From 8f77b08b4ed96af501e071dfeff417f7135b3854 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 23:25:31 -0800 Subject: [PATCH 4/5] test(net): order subscription assertions on a live update Co-Authored-By: GPT-6.1 Sol --- js/net/src/lite/subscriber.test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/js/net/src/lite/subscriber.test.ts b/js/net/src/lite/subscriber.test.ts index a652a6be151..3116e55d5a3 100644 --- a/js/net/src/lite/subscriber.test.ts +++ b/js/net/src/lite/subscriber.test.ts @@ -40,6 +40,7 @@ import { SubscribeOk, type SubscribeResponse, SubscribeStart, + SubscribeUpdate, } from "./subscribe.ts"; import { Minted, SUBSCRIBE_SETUP_TIMEOUT_MS, Subscriber } from "./subscriber.ts"; import { Track, TrackInfo } from "./track.ts"; @@ -1344,11 +1345,12 @@ test.each( for (const chunk of chunks) streams[0].inbound.enqueue(chunk); await track.info(); await request.reading; - await drainReactions(); - const wire = new Reader(undefined, new Uint8Array(Buffer.concat(request.written)), version); - await wire.u53(); - await Subscribe.decode(wire, version); - expect(await wire.done()).toBe(true); + // An explicit change orders after any update caused by TRACK_INFO, even if its encoding yields. + track.update({ priority: 4, delay: { max: Milli(10_000) } }); + const update = await SubscribeUpdate.decode(subscribe, version); + expect([update.priority, update.maxDelay]).toEqual([4, 10_000]); + track.close(); + expect(await subscribe.done()).toBe(true); } finally { track.close(); subscriber.close(); From 79f68a832abcd77ef7dffd9786cf3b79d881940d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 4 Nov 2026 06:28:02 -0800 Subject: [PATCH 5/5] test(net): name subscribe-with-track cases by version and yield mode Bun left the tuple cases' %s placeholders unformatted, so all six shared one literal title. Object cases interpolate $name and $forced instead. Co-Authored-By: Claude Opus 5.5 --- js/net/src/lite/subscriber.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/net/src/lite/subscriber.test.ts b/js/net/src/lite/subscriber.test.ts index 3116e55d5a3..8f140481df5 100644 --- a/js/net/src/lite/subscriber.test.ts +++ b/js/net/src/lite/subscriber.test.ts @@ -1314,9 +1314,9 @@ test("a lite subscribe whose SUBSCRIBE write stalls past the deadline closes its // subscriber waits. test.each( [Version.DRAFT_05, Version.DRAFT_06, Version.DRAFT_07].flatMap((version) => - [false, true].map((forced) => [version, forced] as const), + [false, true].map((forced) => ({ name: versionName(version), version, forced })), ), -)("lite %s: a subscribe goes out with its track (forced yields: %s)", async (version, forced) => { +)("$name: a subscribe goes out with its track (forced yields: $forced)", async ({ version, forced }) => { const yielding = forced ? spyOn(Budget.prototype, "poll").mockImplementation(() => yieldNow()) : undefined; const { quic, streams, opened } = fakeSession(); const subscriber = new Subscriber(quic, version, HopSchema.parse(1n));