diff --git a/quest/m1/test-flakes-2/README.md b/quest/m1/test-flakes-2/README.md index 329fac81ab9..2ba320a6b16 100644 --- a/quest/m1/test-flakes-2/README.md +++ b/quest/m1/test-flakes-2/README.md @@ -38,7 +38,6 @@ Public API: none. Wire: none. - [Auth refresh mocks time](/quest/m1/test-flakes-2/auth-refresh-mock-time.md) - moq-relay's auth refresh and fixed-lease tests measure a grant's life on one mocked clock - [uring teardown close](/quest/m1/test-flakes-2/uring-teardown-close.md) - moq-uring's published-close teardown test holds under load, fixed at its cause - [Relay burst drill](/quest/m1/test-flakes-2/relay-burst-impaired.md) - the impaired transport-peer burst drill never aborts its subscription while the link is up -- [WASM IETF read](/quest/m1/test-flakes-2/wasm-ietf-read.md) - the WASM suite's IETF read case reads whole groups on a loaded runner, fixed at the burst or the assertion as the evidence says - [BBR marking seed](/quest/m1/test-flakes-2/bbr-marking-seed.md) - the BBR marking test seeds its probe schedule, replays a failing seed, and its rare drop is fixed at the cause ## Related diff --git a/quest/m1/test-flakes-2/wasm-ietf-read.md b/quest/m1/test-flakes-2/wasm-ietf-read.md deleted file mode 100644 index 599b2a89341..00000000000 --- a/quest/m1/test-flakes-2/wasm-ietf-read.md +++ /dev/null @@ -1,43 +0,0 @@ -# [S] The WASM IETF read case holds on CI - -## Goal - -The WASM suite's `ietf: reads a published broadcast` case (`test/wasm/src/main.ts`) -passes on loaded CI runners, fixed at its cause. It still proves that a -browser session over moq-transport reads whole groups, in order, from a -published broadcast. - -## Plan - -Seen twice on the WASM job, both as `read 0 whole groups in 8 attempts, want 2`: -run 38778431765 on #5577 (2026-10-15) and run 38607947479 on -`quest/m0/ci/js-select` (2026-10-14). The lite and SETUP flavours of the same -case passed in both. In the first log, group 0 arrives, then about 500 ms -pass with nothing, then groups 1 to 5 arrive within 6 ms and 6 to 8 soon -after, and the reader hits its attempt bound having read none whole. -`expectGroups` treats a group the live edge passed as a legal skip (`isOld`, -from the default `Latency::REAL_TIME`), so every one of those groups was -retired before it was read. - -Find out why the IETF path stalls and then delivers in a burst while lite -does not, and whether retiring a group that arrived whole within the budget, -only because a newer header landed in the same burst, is correct real-time -behaviour. A product bug is fixed in the product. If the behaviour is right -and the case asks for something real-time delivery does not promise, change -what the case asserts, not its attempt bound or timing. Reproduce under CPU -load before deciding. - -Earlier WASM failures of the same case (2026-10-02 to 2026-10-12) failed with -`unsupported`, a different signature; confirm it is gone rather than folding -it in. - -Reopened 2026-10-16 (maintainer): [#5650](https://github.com/moq-dev/moq/pull/5650) -closed this quest by deleting the attempt bound in `expectGroups` (now a bare -`while (read < count)` loop), the change this quest ruled out. It never -reproduced the stall (Chromium did not launch locally) and did not explain -why only IETF stalls about 500 ms and then bursts. With no bound, a -subscription that only ever skips now passes until the case deadline. Find -the cause first, then restore the bound (`count * 4` attempts, or whatever -the cause justifies) in the same PR. - -Public API: none expected. Wire: none. diff --git a/test/wasm/README.md b/test/wasm/README.md index e24367a6898..0c7e79d94b1 100644 --- a/test/wasm/README.md +++ b/test/wasm/README.md @@ -87,7 +87,9 @@ uncovered here. over SETUP) and `ietf` (nothing left to negotiate). - **reads a published broadcast** -- announce, subscribe, and read two consecutive groups, checking every frame byte for byte. One frame is 128 KiB, - which is what exercises the chunked read path in the transport adapter. + which is what exercises the chunked read path in the transport adapter. The + reader asks for each next group, so the real-time subscription never drops one + superseded mid-read, which a timer-paced publisher on a loaded runner did. - **refuses a track the publisher does not serve** -- the refusal has to surface, as a rejected `subscribe` (lite-06, which looks a track's info up first) or as a track that yields no group (IETF, lite-02). A hang fails on the diff --git a/test/wasm/src/main.ts b/test/wasm/src/main.ts index 8af23ac5fee..7a4aa79afaa 100644 --- a/test/wasm/src/main.ts +++ b/test/wasm/src/main.ts @@ -22,7 +22,6 @@ type Wasm = typeof import("@moq/wasm"); type Session = import("@moq/wasm").Session; type Broadcast = import("@moq/wasm").Broadcast; type Track = import("@moq/wasm").Track; -type Group = import("@moq/wasm").Group; /** One relay the suite runs against, and the version it must negotiate. */ export interface RelayFixture { @@ -71,9 +70,6 @@ const FIXTURE: Uint8Array[] = [encode("wasm-frame-0"), encode("wasm-frame-1"), p /** How many consecutive groups the round trip reads before it is satisfied. */ const GROUPS_TO_READ = 2; -/** How often the fixture publisher appends a group. */ -const GROUP_INTERVAL_MS = 50; - function encode(text: string): Uint8Array { return new TextEncoder().encode(text); } @@ -92,8 +88,6 @@ function hexToBytes(hex: string): Uint8Array { return bytes; } -const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); - /** Load and initialize the generated module once per page. */ let loading: Promise | undefined; function load(url: string): Promise { @@ -127,16 +121,25 @@ async function connect(wasm: Wasm, relay: RelayFixture): Promise { } /** - * Publish {@link FIXTURE} on `path` for the duration of `run`, one group every - * {@link GROUP_INTERVAL_MS}. + * Publish {@link FIXTURE} on `path` for the duration of `run`: one group once the + * track has a subscriber, then one more per call to the `advance` handed to `run`. + * + * The reader paces the publisher, not a timer. The wasm subscription has the default + * `Latency::REAL_TIME` budget, which gives up on a group still arriving once a newer + * one lands. A loaded runner can deliver a 128 KiB group slower than any fixed + * interval, so every group is superseded mid-read and none arrives whole. With no + * newer group until the reader asks, whole delivery is guaranteed rather than raced. * - * It keeps publishing rather than writing a fixed number of groups and closing: - * a track that ends before the subscriber's stream is wired up is only reachable - * through the relay's cache, so the test would be measuring retention, and would - * race. A live edge that keeps moving has neither problem. The `missing` track - * is rejected when subscribed, which is what the refusal case reads. + * The track stays open rather than ending after a fixed number of groups: a track + * that ends before the subscriber's stream is wired up is only reachable through + * the relay's cache, so the test would be measuring retention, and would race. The + * `missing` track is rejected when subscribed, which is what the refusal case reads. */ -async function withPublisher(relay: RelayFixture, path: string, run: () => Promise): Promise { +async function withPublisher( + relay: RelayFixture, + path: string, + run: (advance: () => void) => Promise, +): Promise { // The session serves an origin rather than individual broadcasts, so the path is // published into the origin and the session announces the table. const origin = new Moq.Origin.Producer(); @@ -149,18 +152,27 @@ async function withPublisher(relay: RelayFixture, path: string, run: () => Pr const connection = await Moq.Connection.connect({ url: new URL(relay.url), publish: origin.consume() }); let stopped = false; + let wanted = 1; + let wake: (() => void) | undefined; + const advance = () => { + wanted++; + wake?.(); + }; const writer = (async () => { while (!stopped && track.closed.peek() === undefined) { - if (!used.peek()) { - await Promise.race([used.changed(), track.closed]); + if (!used.peek() || wanted === 0) { + const advanced = new Promise((resolve) => { + wake = resolve; + }); + await Promise.race([used.changed(), track.closed, advanced]); continue; } + wanted--; const group = track.appendGroup(); for (const frame of FIXTURE) { group.writeFrame({ payload: frame, timestamp: Moq.Time.Timestamp.now() }); } group.close(); - await Promise.race([sleep(GROUP_INTERVAL_MS), used.changed(), track.closed]); } track.close(); })(); @@ -172,7 +184,7 @@ async function withPublisher(relay: RelayFixture, path: string, run: () => Pr })(); try { - return await run(); + return await run(advance); } finally { stopped = true; track.close(); @@ -206,58 +218,39 @@ async function consume(session: Session, path: string): Promise { } /** - * Read `count` groups off a track and check each one against {@link FIXTURE}. + * Read `count` consecutive groups off a track, asking the publisher for each next one + * with `advance`, and check each against {@link FIXTURE}. * - * The first sequence is whatever the live edge was at subscribe time, so only - * the step between groups is asserted, not the starting number. + * Every group must arrive whole: nothing newer exists while one is read (see + * {@link withPublisher}), so a skip or a short group is a bug, not real-time delivery. + * The first sequence is whatever the live edge was at subscribe time, so only the + * step between groups is asserted, not the starting number. */ -async function expectGroups(track: Track, count: number): Promise { +async function expectGroups(track: Track, count: number, advance: () => void): Promise { let previous: bigint | undefined; - let read = 0; - // A skip is legal (see `isOld`) and real-time delivery puts no bound on how many - // can occur. The case deadline still catches a subscription that makes no progress. - while (read < count) { - let group: Group | undefined; + for (let i = 0; i < count; i++) { + const group = await track.recvGroup(); + if (!group) throw new Error(`track ended after ${i} groups, want ${count}`); try { - group = await track.recvGroup(); - if (!group) throw new Error(`track ended after ${read} groups, want ${count}`); - - // Forward, not consecutive: a skipped group leaves a gap in the sequence. - if (previous !== undefined && group.sequence <= previous) { - throw new Error(`group ${read}: sequence is ${group.sequence}, want greater than ${previous}`); + if (previous !== undefined && group.sequence !== previous + 1n) { + throw new Error(`group ${i}: sequence is ${group.sequence}, want ${previous + 1n}`); } previous = group.sequence; for (const [j, want] of FIXTURE.entries()) { const frame = await group.readFrame(); - if (!frame) throw new Error(`group ${read}: ended after ${j} frames, want ${FIXTURE.length}`); - expectBytes(frame, want, `group ${read} frame ${j}`); + if (!frame) throw new Error(`group ${i}: ended after ${j} frames, want ${FIXTURE.length}`); + expectBytes(frame, want, `group ${i} frame ${j}`); } - if (await group.readFrame()) throw new Error(`group ${read}: got more than ${FIXTURE.length} frames`); - read++; - } catch (err) { - if (!isOld(err)) throw err; + if (await group.readFrame()) throw new Error(`group ${i}: got more than ${FIXTURE.length} frames`); } finally { - group?.free(); + group.free(); } + advance(); } } -/** - * Whether the live edge passed this group before it was delivered whole. - * - * The subscription's budget is the default `Latency::REAL_TIME`, which drops a group - * the edge has moved past rather than delivering it late, so the publisher writing one - * every {@link GROUP_INTERVAL_MS} can legitimately retire a group the reader is still - * on. Treating that as a case failure asserts a guarantee real-time delivery does not - * make, and loses the race on a loaded runner. What has to hold is that a group which - * *is* delivered arrives in order and whole, which the checks above still cover. - */ -function isOld(err: unknown): boolean { - return err instanceof Error && err.message === "old"; -} - function expectBytes(got: Uint8Array, want: Uint8Array, where: string): void { if (got.length !== want.length) throw new Error(`${where}: got ${got.length} bytes, want ${want.length}`); for (let i = 0; i < want.length; i++) { @@ -308,12 +301,12 @@ const CASES: Case[] = [ name: "reads a published broadcast", run: async (wasm, relay) => { const path = `wasm-test/${relay.name}`; - await withPublisher(relay, path, async () => { + await withPublisher(relay, path, async (advance) => { await withSession(wasm, relay, async (session) => { const broadcast = await consume(session, path); const track = await broadcast.subscribe(TRACK); try { - await expectGroups(track, GROUPS_TO_READ); + await expectGroups(track, GROUPS_TO_READ, advance); } finally { track.free(); broadcast.free();