From d7f1dd02772e45b05fc5c701bdf1c1a8edcfcb0c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 9 Nov 2026 01:33:20 -0800 Subject: [PATCH 1/4] chore(quest): claim quest/m0/test-flakes-2/datagram-close-end.md Quest-Claim: 110d8401a5a60313 From 0e26ff39a6cce0ed3a521fd588a5a5c1d6ac93db Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 9 Nov 2026 01:38:14 -0800 Subject: [PATCH 2/4] test(net): order the datagram close-after-end abort by the observed end The reader's recv() resolving to undefined is the client seeing the end, so the abort follows it however delivery is scheduled. Drops the Budget spy and the 10000-turn drain, and re-enables the test. Co-Authored-By: Claude Opus 5.5 --- js/net/src/lite/datagram-tracks.test.ts | 11 ++----- quest/m0/test-flakes-2/README.md | 1 - quest/m0/test-flakes-2/datagram-close-end.md | 30 -------------------- 3 files changed, 3 insertions(+), 39 deletions(-) delete mode 100644 quest/m0/test-flakes-2/datagram-close-end.md diff --git a/js/net/src/lite/datagram-tracks.test.ts b/js/net/src/lite/datagram-tracks.test.ts index ded3c095732..7ffe5376291 100644 --- a/js/net/src/lite/datagram-tracks.test.ts +++ b/js/net/src/lite/datagram-tracks.test.ts @@ -471,7 +471,7 @@ for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) { 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"); @@ -484,13 +484,8 @@ 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. - const budget = spyOn(Budget.prototype, "poll").mockImplementation(() => undefined); // Runs even when the test times out with a wait still pending. onTestFinished(() => { - budget.mockRestore(); reader.close(); remote.close(); client.abort(); @@ -500,8 +495,8 @@ for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) { await reader.info(); while (datagrams.priority.peek() !== 5) await datagrams.priority.changed(); datagrams.finish(); - // The mock delivers the end in microtasks, all within this host task. - for (let i = 0; i < 10000; i++) await Promise.resolve(); + // The reader observing the end orders the abort after it, however the delivery is scheduled. + expect(await reader.recv()).toBeUndefined(); 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 8e83f1a21a4..0e0841d36ac 100644 --- a/quest/m0/test-flakes-2/README.md +++ b/quest/m0/test-flakes-2/README.md @@ -245,4 +245,3 @@ Public API: none. Wire: none. - [js/net's compressed-frame cap test holds up under load](/quest/m0/test-flakes-2/compressed-frame-cap.md) - the cap is proven without a 32 MiB payload, and its `test.skip` is removed - [js/net's lite-07 re-dropped re-offer test holds up under load](/quest/m0/test-flakes-2/redropped-reoffer.md) - update 3 is ordered before the re-offer opens by an event, not a yield count, and its `test.skip` is removed - [moq-net's random-mesh withdrawal tests fit the gate](/quest/m0/test-flakes-2/mesh-withdraw-runtime.md) - the 200-seed mesh tests cost seconds of CPU, and their `#[ignore]` 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 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. From e6ee5dde90358bc8f59474fcb59a602c0ffaba8e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 9 Nov 2026 01:47:25 -0800 Subject: [PATCH 3/4] test(net): abort inside the datagram end's routing window Synchronize on the subscriber starting the host-task wait that routes the end, so the abort lands after the client took the end and before it finishes the reader, which is the window close() must preserve. Co-Authored-By: Claude Opus 5.5 --- js/net/src/lite/datagram-tracks.test.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/js/net/src/lite/datagram-tracks.test.ts b/js/net/src/lite/datagram-tracks.test.ts index 7ffe5376291..d071744ad33 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"; @@ -469,8 +470,6 @@ 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(`${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 }); @@ -484,8 +483,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); + // 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(); @@ -494,9 +499,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 reader observing the end orders the abort after it, however the delivery is scheduled. - expect(await reader.recv()).toBeUndefined(); + await received.promise; client.abort(); expect(await reader.recv()).toBeUndefined(); }); From 6c0f52c63626326df19f426bb531fbffd90c9c60 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 9 Nov 2026 15:25:06 -0800 Subject: [PATCH 4/4] quest: record the datagram close-after-end fix in the epic README --- quest/m0/test-flakes-2/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quest/m0/test-flakes-2/README.md b/quest/m0/test-flakes-2/README.md index 8e472479ef3..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