diff --git a/js/net/src/lite/datagram-tracks.test.ts b/js/net/src/lite/datagram-tracks.test.ts index 88097f23520..6be4ab8f6db 100644 --- a/js/net/src/lite/datagram-tracks.test.ts +++ b/js/net/src/lite/datagram-tracks.test.ts @@ -1,4 +1,5 @@ import { expect, onTestFinished, spyOn, test } from "bun:test"; +import * as clock from "@moq/clock"; import { yieldNow } from "@moq/clock"; import { Signal } from "@moq/signals"; import { accept, connect } from "../connection/index.ts"; @@ -470,9 +471,7 @@ for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) { // A track's end waits a host task for the datagrams received with it. A session close in // between finishes the track rather than cutting it off: the publisher already ended it. for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) { - // Quarantined: fails in the merge queue with "Session: remote error: 0" (lite-06 on #8280, lite-05 on - // #8276 after #8321 re-enabled it). /quest/m0/test-flakes-2/datagram-close-end.md - test.skip(`${alpn}: a session close right after a datagram track's end keeps the end`, async () => { + test(`${alpn}: a session close right after a datagram track's end keeps the end`, async () => { const source = new Origin(); const publication = source.route(path, { hidden: true }); const datagrams = publication.broadcast.createDatagrams("audio"); @@ -485,13 +484,14 @@ for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) { const remote = wireOf(client).consume(path); const reader = remote.datagrams("audio"); reader.setPriority(5); - // The end has to reach the client before the abort, and the mock delivers it in - // microtasks. A write-budget yield is a host task that the drain below can't advance, - // so under CPU load the publisher's answer could still be stalled when the abort lands. + // Only the end's routing yields a host task after the finish below: the receive loop's + // budget never runs out here. const budget = spyOn(Budget.prototype, "poll").mockImplementation(() => undefined); + let routing: ReturnType | undefined; // Runs even when the test times out with a wait still pending. onTestFinished(() => { budget.mockRestore(); + routing?.mockRestore(); reader.close(); remote.close(); client.abort(); @@ -500,9 +500,15 @@ for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) { }); await reader.info(); while (datagrams.priority.peek() !== 5) await datagrams.priority.changed(); + // The client marks the end taken, then waits a host task to route what arrived with it. + const received = Promise.withResolvers(); + const hostTask = clock.yieldNow; + routing = spyOn(clock, "yieldNow").mockImplementation(() => { + received.resolve(); + return hostTask(); + }); datagrams.finish(); - // The mock delivers the end in microtasks, all within this host task. - for (let i = 0; i < 10000; i++) await Promise.resolve(); + await received.promise; client.abort(); expect(await reader.recv()).toBeUndefined(); }); diff --git a/quest/m0/test-flakes-2/README.md b/quest/m0/test-flakes-2/README.md index 455f9c7c049..fbc232e14b3 100644 --- a/quest/m0/test-flakes-2/README.md +++ b/quest/m0/test-flakes-2/README.md @@ -233,7 +233,9 @@ Added 2026-11-09 (maintainer's standing rule that flakes join this epic): `js/net`'s datagram session-close-after-end test again, whose lite-05 case failed the merge queue for [moq-dev/moq#8276](https://github.com/moq-dev/moq/pull/8276) after [moq-dev/moq#8321](https://github.com/moq-dev/moq/pull/8321) re-enabled it. -It is quarantined with `test.skip` for every version until its child fixes it. +The test now aborts once the client has recorded the end, signalled by the +subscriber's `yieldNow()`, and is re-enabled by +[moq-dev/moq#8357](https://github.com/moq-dev/moq/pull/8357). Added 2026-11-09 (maintainer's standing rule that flakes join this epic): moq-rs's Python socket test `test_tcp_rst_and_endpoint_close_are_errors`, whose @@ -247,5 +249,4 @@ Public API: none. Wire: none. - [Fallback playback](/quest/m0/test-flakes-2/ietf22-fallback.md) - a browser viewer follows a fallback within the media lane's bound without dropping its session - [js/net's bandwidth sampling test holds up under load](/quest/m0/test-flakes-2/bandwidth-sampling.md) - the sampling test counts ticks without racing the mocked clock, and its `test.skip` is removed -- [js/net's datagram session-close-after-end test holds up under load](/quest/m0/test-flakes-2/datagram-close-end.md) - the abort is ordered after the end by an event the client observes, and its `test.skip` is removed - [js/net's lite-07 datagram queue test holds up under load](/quest/m0/test-flakes-2/datagram-queues.md) - the test waits for the first track's queue instead of asserting at once, and its `test.skip` is removed diff --git a/quest/m0/test-flakes-2/datagram-close-end.md b/quest/m0/test-flakes-2/datagram-close-end.md deleted file mode 100644 index f5ff0071f8c..00000000000 --- a/quest/m0/test-flakes-2/datagram-close-end.md +++ /dev/null @@ -1,30 +0,0 @@ -# [S] js/net's datagram session-close-after-end test holds up under load - -## Goal - -`js/net/src/lite/datagram-tracks.test.ts`'s "a session close right after a -datagram track's end keeps the end" passes in the merge queue for every -version it covers, and its `test.skip` is removed. - -## Plan - -Planned 2026-11-09 (maintainer's standing rule that flakes join this epic). -The lite-06 case dropped -[moq-dev/moq#8280](https://github.com/moq-dev/moq/pull/8280) from the merge -queue and was quarantined; [moq-dev/moq#8321](https://github.com/moq-dev/moq/pull/8321) -re-enabled it with no fix after finding no repro; its investigation, which rules -out microtask reordering and names `Budget` before `connect` and `now()` in -`group.ts`/`cache.ts` as the real-time suspects, stays in its PR body. The -lite-05 case then failed the merge queue for -[moq-dev/moq#8276](https://github.com/moq-dev/moq/pull/8276) with `Session: -remote error: 0`: the reader saw the abort before the end. The land fixer's -note on #8276 records 20 clean repeats of the file on a scratch merge, so it -fails only under the queue's load. - -The test assumes 10000 microtask turns deliver the publisher's end before -`client.abort()`. Find the step that still crosses a host task under load, and -order the abort after the end by an event the client observes (such as the -reader's track reaching its end state), never by more turns or a sleep. Then -remove the `test.skip` and delete this quest. - -Public API: none. Wire: none.