diff --git a/js/net/src/lite/widened_max_age.test.ts b/js/net/src/lite/widened_max_age.test.ts index 8b6f87d2c1a..eb5320421ec 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. - reader.update({ priority: 5 }); - const before = now(); + // 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, delay: { max: Milli(1500) } }); + 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 61b115b76e4..e126d9f87e8 100644 --- a/quest/m0/test-flakes-2/README.md +++ b/quest/m0/test-flakes-2/README.md @@ -235,7 +235,6 @@ 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 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 - [bench/relay.test.py's stream-transport test gets a port free for TCP and UDP](/quest/m0/test-flakes-2/relay-port-pair.md) - the test binds TCP and UDP to one number free in both, so parallel checks can't collide with it - [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 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.