From c14f4c0a4093f394cdf00b517f5cabd152eabd52 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 8 Nov 2026 09:26:57 -0800 Subject: [PATCH 1/3] chore(quest): claim quest/m0/test-flakes-2/widened-max-age-reset.md Quest-Claim: 48b7b9d01691a62d From ba992ae90fade970acedb9684d5378bcae0ce446 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 8 Nov 2026 09:52:19 -0800 Subject: [PATCH 2/3] test(net): the widened max-age re-drop test ends after the re-drop lands The "keeping the budget" lite-07 test finished the track right after its priority-only update, racing the publisher's reply that re-drops the stale groups. When the end won, the reply was reset with Cancel and the reader failed with it. The test now waits until the reader holds the re-drop of groups 1 and 2 under the new update, then finishes the track, so the end is a FIN. The wait is event-driven, so a missing re-drop still fails, and the 500 ms wall-clock assert it replaces is gone. Co-Authored-By: Claude Haiku 5.5 --- js/net/src/lite/widened_max_age.test.ts | 31 +++++++++++++--- quest/m0/test-flakes-2/README.md | 1 - .../m0/test-flakes-2/widened-max-age-reset.md | 35 ------------------- 3 files changed, 26 insertions(+), 41 deletions(-) delete mode 100644 quest/m0/test-flakes-2/widened-max-age-reset.md diff --git a/js/net/src/lite/widened_max_age.test.ts b/js/net/src/lite/widened_max_age.test.ts index 8b6f87d2c1a..3379fc0678a 100644 --- a/js/net/src/lite/widened_max_age.test.ts +++ b/js/net/src/lite/widened_max_age.test.ts @@ -2,8 +2,9 @@ // as stale, including those below where SUBSCRIBE_START resolved, and never one twice. import { expect, test } from "bun:test"; -import { Milli, now } from "@moq/clock"; +import { Milli } from "@moq/clock"; import { accept, connect } from "../connection/index.ts"; +import { hooks } from "../internal.ts"; import { createMockTransportPair } from "../mock.ts"; import { Producer as OriginProducer } from "../origin.ts"; import * as Path from "../path.ts"; @@ -25,6 +26,25 @@ async function received(reader: TrackSubscriber, count: number): Promise (a < b ? -1 : a > b ? 1 : 0)); } +/** + * Resolves once the publisher's re-drop of groups 1 and 2 reaches `reader`: the update clears + * their stale verdict, and the drop under the update's number sets it again. Each change is + * heard as it lands, so the clear is seen even when the re-drop follows it at once. + */ +function redropped(reader: TrackSubscriber): Promise { + return new Promise((resolve) => { + let cleared = false; + const dispose = hooks.givenUp(reader, 1n).changed.subscribe(() => { + const held = hooks.staleHeld(reader, 1n, 3n); + if (held.length === 0) cleared = true; + else if (cleared && held.length === 1 && held[0].start === 1n && held[0].end === 3n) { + dispose(); + resolve(); + } + }); + }); +} + test("a widened maxDelay re-offers what the publisher skipped below the start", async () => { const pair = createMockTransportPair(ALPN_07_WIP); const origin = new OriginProducer(); @@ -193,14 +213,15 @@ test("an update keeping the budget drops the stale groups again on lite-07", asy } expect(await received(reader, 2)).toEqual([3n, 4n]); - // Only the priority changes: groups 1 and 2 are still stale, so they are dropped again. + // Only the priority changes: groups 1 and 2 are still stale, so they are dropped again. The + // track ends only once that re-drop has reached the reader, so the end is a FIN, not a reset + // of the reply still writing; a missing re-drop fails here instead of waiting out the grace. + const reached = redropped(reader); reader.update({ priority: 5 }); - const before = now(); + await reached; producer.finish(); producer.close(); expect(await reader.recvGroup()).toBeUndefined(); - // Well inside the 1.5s grace a missing re-drop would wait out, in nanoseconds. - expect(now() - before).toBeLessThan(500_000_000); reader.close(); remote.close(); diff --git a/quest/m0/test-flakes-2/README.md b/quest/m0/test-flakes-2/README.md index 199497632b4..d69d8e0bc4c 100644 --- a/quest/m0/test-flakes-2/README.md +++ b/quest/m0/test-flakes-2/README.md @@ -210,4 +210,3 @@ 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 - [moq-relay's forged-dial test waits for bob's endpoint](/quest/m0/test-flakes-2/forged-dial-announce.md) - `a_forged_dial_never_connects` requests bob's endpoint only after its announce reaches mallory, and its `#[ignore]` is removed - [moq-uring's qlog accounting test waits on the accounting](/quest/m0/test-flakes-2/qlog-staging-spin.md) - `an_open_trace_accounts_for_staging_and_close` waits for the accounting, not 10,000 spins -- [js/net's widened max-age re-drop test ends cleanly, not with a reset](/quest/m0/test-flakes-2/widened-max-age-reset.md) - the test finishes the track only after the re-drop reply arrives, so the end is a FIN, and drops its wall-clock assert diff --git a/quest/m0/test-flakes-2/widened-max-age-reset.md b/quest/m0/test-flakes-2/widened-max-age-reset.md deleted file mode 100644 index 735a187d4ce..00000000000 --- a/quest/m0/test-flakes-2/widened-max-age-reset.md +++ /dev/null @@ -1,35 +0,0 @@ -# [XS] js/net's widened max-age re-drop test ends cleanly, not with a reset - -## Goal - -`js/net`'s "an update keeping the budget drops the stale groups again on -lite-07" cannot flake. It finishes the track only after the re-drop reply has -reached the subscriber, so the end arrives as a FIN, and it detects a missing -re-drop without a wall-clock deadline. - -## Plan - -Planned 2026-11-08 (maintainer, /quest-complete), a follow-up of -[moq-dev/moq#8230](https://github.com/moq-dev/moq/pull/8230), whose iterate -saw it fail there and on unrelated branches, then pass on rerun. - -The observed failure (8230's `Check`, job 128649627407) took 9.30 ms: -`recvGroup()` rejected with `reset stream: 1` (`StreamCode.Cancel`), thrown -from `js/net/src/lite/publisher.ts`'s `response()`. When the stream ends -while a reply write is blocked on the write budget, `response()` resets the -writable half with `Cancel`. Here the reader's priority-only update sends a -reply while the producer finishes, so the clean end can lose to the reset. -The test's 500 ms elapsed assert never ran. - -The reset is intended: -[moq-dev/moq#8195](https://github.com/moq-dev/moq/pull/8195) rejected letting a -clean FIN override a pending reply write, since that write could block on flow -control for a peer that has left. So the race is in the test, which finishes -the producer right after `reader.update()` without waiting for the re-drop -reply. Fix the test, not the publisher: wait until the subscriber has received -the re-drop of groups 1 and 2 under the new update, then finish the producer. -That wait also replaces the 500 ms elapsed assert. Bound it on the `Manual` -clock, or by event, so a missing re-drop (which would otherwise wait out the -1.5 s grace) still fails while a CI pause cannot. - -Public API: none. Wire: none. From 6a28e245508863d8f043f60ba05d3f050b033bbd Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 8 Nov 2026 23:44:09 -0800 Subject: [PATCH 3/3] test(js/net): keep the 1500 ms budget on the priority-only update Co-Authored-By: Claude Opus 5.5 --- js/net/src/lite/widened_max_age.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/net/src/lite/widened_max_age.test.ts b/js/net/src/lite/widened_max_age.test.ts index 3379fc0678a..eb5320421ec 100644 --- a/js/net/src/lite/widened_max_age.test.ts +++ b/js/net/src/lite/widened_max_age.test.ts @@ -213,11 +213,11 @@ test("an update keeping the budget drops the stale groups again on lite-07", asy } expect(await received(reader, 2)).toEqual([3n, 4n]); - // Only the priority changes: groups 1 and 2 are still stale, so they are dropped again. The + // Only the priority changes (the budget is resent, since an update replaces it): groups 1 and 2 are still stale, so they are dropped again. The // track ends only once that re-drop has reached the reader, so the end is a FIN, not a reset // of the reply still writing; a missing re-drop fails here instead of waiting out the grace. const reached = redropped(reader); - reader.update({ priority: 5 }); + reader.update({ priority: 5, delay: { max: Milli(1500) } }); await reached; producer.finish(); producer.close();