diff --git a/js/net/src/group.ts b/js/net/src/group.ts index a02535d7d1..06422451f9 100644 --- a/js/net/src/group.ts +++ b/js/net/src/group.ts @@ -1140,6 +1140,7 @@ export class Consumer { hooks.expireGroup = (group, expiry) => { group.#expiry = expiry; }; + hooks.groupExpiry = (group) => group.#expiry; hooks.groupFailed = (group) => group.#failed(); hooks.recoverGroup = (group, recover) => { group.#recover = recover; diff --git a/js/net/src/internal.ts b/js/net/src/internal.ts index d517d3172d..6d13c15bfb 100644 --- a/js/net/src/internal.ts +++ b/js/net/src/internal.ts @@ -872,8 +872,11 @@ export const hooks: { * subscriber's own record. Mirrors the Rust crate-private `track::Subscriber::record_mut`. */ wire: (subscriber: Subscriber) => WireRecord; - /** Whether this subscriber's budget gives up on `key`, judged by its successor; see {@link expireGroup}. */ - staleAt: (subscriber: Subscriber, key: bigint) => Expiry; + /** + * Whether this subscriber's budget, or `budget` in milliseconds when given, gives up on `key`, + * judged by its successor; see {@link expireGroup}. + */ + staleAt: (subscriber: Subscriber, key: bigint, budget?: number) => Expiry; /** A group the subscriber's track still caches, as a fresh read handle. */ cachedGroup: (subscriber: Subscriber, key: bigint, from?: number) => GroupConsumer | undefined; /** @@ -1009,6 +1012,8 @@ export const hooks: { arriveGroup: (group: GroupConsumer, at: Instant) => void; /** Keep applying a subscription's drift policy after it hands a group out. */ expireGroup: (group: GroupConsumer, expiry: Expiry) => void; + /** The drift policy a group carries, if any; see {@link expireGroup}. */ + groupExpiry: (group: GroupConsumer) => Expiry | undefined; /** The failure that ends a group's reader, as its `closed` would settle, without building that handle. */ groupFailed: (group: GroupConsumer) => Error | undefined; /** @@ -1416,6 +1421,9 @@ export const hooks: { expireGroup: () => { throw new Error("group.ts not loaded"); }, + groupExpiry: () => { + throw new Error("group.ts not loaded"); + }, groupFailed: () => { throw new Error("group.ts not loaded"); }, diff --git a/js/net/src/lite/publisher.test.ts b/js/net/src/lite/publisher.test.ts index 86f5cd3c6d..d393bf9c8b 100644 --- a/js/net/src/lite/publisher.test.ts +++ b/js/net/src/lite/publisher.test.ts @@ -4,6 +4,7 @@ import { Manual } from "@moq/clock/test"; import { Signal } from "@moq/signals"; import type { Grant } from "../auth.ts"; import { Producer as BroadcastProducer } from "../broadcast.ts"; +import { accept as acceptSession, connect as connectSession } from "../connection/index.ts"; import { fromTransport, ProtocolViolation, SessionCode, StreamCode, StreamError, toStreamCode } from "../error.ts"; import { Consumer as GroupConsumer, type Producer as GroupProducer } from "../group.ts"; import { randomHop } from "../hop.ts"; @@ -3470,6 +3471,7 @@ test("lite draft-07: a fetch sent whole resets as too old when it goes stale una // The FIN is never acknowledged: the close stays pending until the stream resets. const inner = accepted.value.writable.getWriter(); let reset: unknown; + const { promise: closing, resolve: closed } = Promise.withResolvers(); const writable = new WritableStream({ start(controller) { controller.signal.addEventListener("abort", () => { @@ -3478,7 +3480,10 @@ test("lite draft-07: a fetch sent whole resets as too old when it goes stale una }); }, write: (chunk) => inner.write(chunk), - close: () => new Promise(() => undefined), + close: () => { + closed(); + return new Promise(() => undefined); + }, }); const server = new Stream({ readable: accepted.value.readable, writable, version: Version.DRAFT_07 }); @@ -3492,8 +3497,7 @@ test("lite draft-07: a fetch sent whole resets as too old when it goes stale una }); const serving = publisher.runFetch(msg, server); // The whole group and its FIN go out before any successor arrives. - await client.reader.u8(); - await flush(); + await closing; expect(reset).toBeUndefined(); // Then the track runs a second past its successor, with the FIN still unacknowledged. @@ -3512,6 +3516,91 @@ test("lite draft-07: a fetch sent whole resets as too old when it goes stale una } }); +// A relay serving a FETCH for a broadcast it consumes over the wire judges the reply by the +// FETCH's own budget too, against a copy of the track a live reader subscribed, as a Rust relay +// judges the fetch it landed in that copy's cache. +test("lite draft-07: a relayed fetch sent whole resets as too old when it goes stale unacknowledged", async () => { + // Upstream: the broadcast's origin, consumed by the relay over a session. + const upstream = createMockTransportPair(ALPN_07_WIP); + const source = new OriginProducer(); + const broadcast = publish(source, Path.from("live")); + const track = broadcast.createTrack("video", { timescale: Timescale.MILLI, maxAge: null }); + const frame = (ms: number) => ({ payload: new TextEncoder().encode("x"), timestamp: Timestamp.fromMillis(ms) }); + const whole = track.createGroup(0n); + whole.writeFrame(frame(0)); + whole.finish(); + const url = new URL("https://localhost:4443/test"); + const [session, upstreamServer] = await Promise.all([ + connectSession({ url, transport: upstream.client }), + acceptSession({ transport: upstream.server, url, publish: source.consume() }), + ]); + const front = new Front(); + front.serve(wireOf(session).consume(Path.from("live"))); + + // Downstream: the relay's publisher, answering with the front. + const pair = createMockTransportPair(ALPN_07_WIP); + const origin = new OriginProducer(); + const dynamic = origin.claim(Path.from("live")); + void (async () => { + for await (const request of dynamic.requested()) request.serve(front.consumer); + })(); + const publisher = new Publisher(pair.server, Version.DRAFT_07, randomHop(), origin.consume()); + + const client = await Stream.open(pair.client, { version: Version.DRAFT_07 }); + const incoming = pair.server.incomingBidirectionalStreams.getReader(); + const accepted = await incoming.read(); + incoming.releaseLock(); + if (accepted.done) throw new Error("publisher never accepted the fetch stream"); + // The FIN is never acknowledged: the close stays pending until the stream resets. + const inner = accepted.value.writable.getWriter(); + let reset: unknown; + const { promise: closing, resolve: closed } = Promise.withResolvers(); + const writable = new WritableStream({ + start(controller) { + controller.signal.addEventListener("abort", () => { + reset = controller.signal.reason; + void inner.abort(controller.signal.reason); + }); + }, + write: (chunk) => inner.write(chunk), + close: () => { + closed(); + return new Promise(() => undefined); + }, + }); + const server = new Stream({ readable: accepted.value.readable, writable, version: Version.DRAFT_07 }); + + // Another downstream reader, whose own budget is far wider, keeps a copy subscribed. + const live = front.consumer.track("video").subscribe({ delay: { max: Duration.millis(3_600_000) } }); + try { + const msg = new Fetch({ broadcast: Path.from("live"), track: "video", priority: 0, maxDelay: 500, group: 0n }); + const serving = publisher.runFetch(msg, server); + // The whole group and its FIN go out before any successor arrives. + await closing; + expect(reset).toBeUndefined(); + + // Then the track runs a second past its successor upstream, with the FIN still unacknowledged. + for (const ms of [1000, 2000]) { + const group = track.createGroup(BigInt(ms / 1000)); + group.writeFrame(frame(ms)); + group.finish(); + } + await serving; + expect(toStreamCode(fromTransport(reset))).toBe(StreamCode.Old); + } finally { + live.close(); + publisher.close(); + client.close(); + dynamic.close(); + front.consumer.close(); + session.close(); + upstreamServer.close(); + broadcast.close(); + source.close(); + origin.close(); + } +}); + test.each([0, 1])("lite draft-07 reports the cached largest position when starting at time %s", async (start) => { const startGroup = BigInt(start); const version = Version.DRAFT_07; diff --git a/js/net/src/resume.test.ts b/js/net/src/resume.test.ts index fdf27310eb..fcb8efb12e 100644 --- a/js/net/src/resume.test.ts +++ b/js/net/src/resume.test.ts @@ -1949,6 +1949,65 @@ test("a fetched group continues from the next route once its own fails", async ( b.close(); }); +// A wire answers a FETCH with a bare group, which carries no budget of its own: the fetch's own +// budget judges it against a reader's copy of the route, as a Rust relay judges a fetch landed in +// that copy's cache. Nothing newer is known before a reader subscribes one, and a fetch never does. +test.each([ + { budget: "500ms", maxDelay: Duration.millis(500), stale: true, bounded: false }, + { budget: "none", maxDelay: undefined, stale: false, bounded: false }, + // Judged against the whole track, as a fetch is, not the window of the reader it picked. + { budget: "500ms, beside a bounded reader", maxDelay: Duration.millis(500), stale: true, bounded: true }, +])( + "a group fetched over a wire goes stale by the fetch's own budget ($budget)", + async ({ maxDelay, stale, bounded }) => { + // Still, so only presentation time judges. + const { installed } = manual(); + const front = new Front(); + const a = new BroadcastProducer(); + const ta = copy(a); + ta.write(0n); + const { route } = counted(a, (key) => { + const answer = new GroupProducer(key); + answer.writeFrame({ payload: enc.encode(`${key}.0`), timestamp: Timestamp.unscaled(answer.start) }); + answer.finish(); + return answer.consume(); + }); + front.serve(route); + try { + const group = await front.consumer.track("seq").fetchGroup(0n, { maxDelay }); + ta.write(1000n); + await settle(); + // Fetch-only: nothing pulls the track, so nothing newer is known here. + expect(ta.producer.demand().wanted.peek()).toBe(false); + expect(group.expired.peek()).toBeUndefined(); + // Listening before any copy exists, so a copy subscribed later has to wake it. + const verdict = new Promise((resolve) => void group.expired.then(resolve)); + + // A reader of group 0 alone subscribes the first copy, and a live one whose own budget is + // far wider the next. + const first = bounded + ? front.consumer.track("seq").subscribe({ ranges: [{ start: { time: 0n }, end: { time: 0n } }] }) + : undefined; + const sub = front.consumer.track("seq").subscribe({ delay: { max: Duration.millis(3_600_000) } }); + await settle(); + expect(group.expired.peek()).toBeUndefined(); + + // The copy's live edge runs a second past group 0's successor. + ta.write(2000n); + if (stale) expect(await verdict).toMatchObject({ code: StreamCode.Old }); + else expect(await isPending(verdict)).toBe(true); + + first?.close(); + sub.close(); + group.close(); + } finally { + front.consumer.close(); + a.close(); + installed.close(); + } + }, +); + test("a held fetch lets go of the route it resumed onto once its reader releases the group", async () => { const front = new Front(); const a = new BroadcastProducer(); diff --git a/js/net/src/resume.ts b/js/net/src/resume.ts index a37c0f6c85..67bf441b5b 100644 --- a/js/net/src/resume.ts +++ b/js/net/src/resume.ts @@ -54,6 +54,7 @@ import type { Consumer as GroupConsumer } from "./group.ts"; import { type Ask, type DropRun, + type Expiry, finalKey, type GroupRecover, hooks, @@ -222,6 +223,8 @@ class Route { readonly readers = new Set(); /** Called once the last reader leaves. */ idle: () => void = () => {}; + /** Called once a reader subscribes a copy, or moves one onto a new source. */ + copied: () => void = () => {}; constructor(name: string) { this.name = name; @@ -534,6 +537,7 @@ class Reader implements ResumeSource { this.#bound(copy); this.#copies.push(copy); this.wake(); + route.copied(); return; } const asked: Pick = { floor: this.#newest }; @@ -584,6 +588,7 @@ class Reader implements ResumeSource { source.retain(); this.#bound(copy); this.#copies.splice(index, 0, copy); + this.route.copied(); const shell = this.#shell; const record = this.#record; copy.sub.info().then( @@ -779,6 +784,13 @@ class Reader implements ResumeSource { this.#changed.update((n) => n + 1); } + /** The newest open copy this reader holds of `source`'s broadcast. */ + copyOn(source: Source): Copy | undefined { + return this.#copies.findLast( + (copy) => copy.source.from.closed === source.from.closed && copy.sub.closed.peek() === undefined, + ); + } + /** The reader's copy of the route at `generation`, if it subscribed one, rather than a backfill of it. */ copy(generation: number): Copy | undefined { return this.#copies.findLast((copy) => copy.generation === generation); @@ -2001,6 +2013,64 @@ class Recover implements GroupRecover { } } +/** + * A fetched group's own budget, in milliseconds, judged against a reader's copy of its track on + * the route it came from, as the Rust relay judges a fetch landed in that copy's cache. It opens + * no subscription, so a fetch-only relay never pulls the track: with no copy, nothing newer is + * known here, and the group is never stale. + */ +class FetchExpiry implements Expiry { + readonly changed: readonly Getter[]; + #find: () => Copy | undefined; + #key: bigint; + #budget: number; + // The copy judging the group. One that closed still judges by what it held, until another opens. + #judging?: { sub: track.Subscriber; expiry: Expiry; unwatch: Dispose[] }; + // Bumped whenever the judging copy's verdict may change. + #relay = new Signal(0); + #closed = false; + + constructor(find: () => Copy | undefined, copied: Getter, key: bigint, budget: number) { + this.#find = find; + this.#key = key; + this.#budget = budget; + this.changed = [copied, this.#relay]; + } + + expired(): boolean { + this.#pick(); + return this.#judging?.expiry.expired() ?? false; + } + + /** Judge afresh once the group moves to another route: the old route's copy says nothing about it. */ + moved(): void { + this.#unwatch(); + this.#judging = undefined; + this.#relay.update((n) => n + 1); + } + + /** Stop watching the copy, once nobody reads the group. */ + close(): void { + this.#closed = true; + this.#unwatch(); + } + + #pick(): void { + const found = this.#find(); + if (!found || found.sub === this.#judging?.sub) return; + this.#unwatch(); + const expiry = hooks.staleAt(found.sub, this.#key, this.#budget); + const bump = () => this.#relay.update((n) => n + 1); + const unwatch = this.#closed ? [] : expiry.changed.map((changed) => changed.subscribe(bump)); + this.#judging = { sub: found.sub, expiry, unwatch }; + } + + #unwatch(): void { + for (const dispose of this.#judging?.unwatch ?? []) dispose(); + if (this.#judging) this.#judging.unwatch = []; + } +} + /** * One broadcast served through one route at a time; see the module docs. * @@ -2020,6 +2090,8 @@ export class Front { #info = new Map(); /** Bumped whenever the source changes, so an answer from a replaced one is dropped. */ #changed = new Signal(0); + /** Bumped whenever a reader subscribes a copy, which may judge a fetched group; see {@link FetchExpiry}. */ + #copied = new Signal(0); /** Aborted once the current source is replaced, retiring what was asked of it. */ #retire = new AbortController(); #concluded = false; @@ -2290,6 +2362,7 @@ export class Front { created.idle = () => { if (this.#routes.get(name) === created) this.#routes.delete(name); }; + created.copied = () => this.#copied.update((n) => n + 1); this.#routes.set(name, created); // A track whose properties another source already gave is checked like any replacement. if (this.#concluded) created.conclude(); @@ -2401,6 +2474,16 @@ export class Front { async fetchGroup(name: string, key: bigint, options?: track.FetchGroupOptions): Promise { const fetched = await this.#fetch(name, key, options); let current = fetched.source; + // A group fetched over a wire carries no budget of its own, unlike one a local track + // answers: the fetch's own budget judges it against a copy of the route it came from. + const judge = new FetchExpiry( + () => this.#copyOn(name, current), + this.#copied, + key, + options?.maxDelay?.asMillis() ?? Number.POSITIVE_INFINITY, + ); + const expiry = (group: GroupConsumer) => hooks.groupExpiry(group) ?? judge; + if (!hooks.groupExpiry(fetched.group)) hooks.expireGroup(fetched.group, judge); // Too old and evicted judge a subscription's delivery, not whether the group exists, so // neither is a verdict on a fetch: one answered from a group still arriving over a // subscription asks the route again for the rest when that delivery gives up on it. @@ -2425,11 +2508,11 @@ export class Front { // The fetch's hold on its route passes to the group on adoption, or goes with the discard. return { group: next.group, - // The route applies the fetch's own budget. - expiry: { expired: () => false, changed: [] }, + expiry: expiry(next.group), adopt: () => { current.release(); current = next.source; + judge.moved(); // Its fetch may hold its subscription until its reader lets go, and the // reader is now `fetched.group`. void hooks.groupReleased(fetched.group).then(() => next.group.close()); @@ -2441,12 +2524,29 @@ export class Front { }; }, }); - // Only once the group carries its recovery: reading `closed` before then would settle it - // on a failure recovery could still continue, releasing the route while it is read. + // Only once the group carries its recovery: reading `closed` or `done` before then would + // settle it on a failure recovery could still continue, releasing the route, or ending + // the budget's watch, while it is read. void fetched.group.closed.then(() => current.release()); + // The budget is watched for as long as the group is read, or until released while a held + // reply awaits its acknowledgement, as the fetch's own subscription is. + void ( + (options as broadcast.FetchFrom | undefined)?.held + ? hooks.groupReleased(fetched.group) + : hooks.groupDone(fetched.group) + ).then(() => judge.close()); return fetched.group; } + // The newest open copy of track `name` a reader holds of `source`'s broadcast, if any. + #copyOn(name: string, source: Source): Copy | undefined { + for (const reader of this.#routes.get(name)?.readers ?? []) { + const copy = reader.copyOn(source); + if (copy) return copy; + } + return undefined; + } + // Fetch a group from whichever route serves the track, asking the next one when a route // fails, and never `avoid`. The source comes back retained for as long as the group is read. // Once no route will come, it ends with `ended`, or as not found. diff --git a/js/net/src/track.ts b/js/net/src/track.ts index 93c029ad15..2306be7393 100644 --- a/js/net/src/track.ts +++ b/js/net/src/track.ts @@ -2895,6 +2895,8 @@ type Drift = { // track's bare starts count as milliseconds, as the Rust `age` reads them. presentation?: { key: bigint; at: number }; end?: bigint; + // Judged against the whole track rather than this reader's window, as a fetch is. + whole: boolean; }; // An ordered read's state, mirroring the Rust `Ordered`: a group read and held back because a gap @@ -3119,10 +3121,10 @@ export class Subscriber { // handler could take it. #lookups: { time: bigint; lookup?: Lookup }[] = []; - #drift(): Drift { + #drift(whole = this.#fetchBudget !== undefined): Drift { // A fetch judges its group against the whole track, as the Rust `fetch_group` does: a // newer group outside its one-group window still supersedes it. - const end = this.#fetchBudget === undefined ? this.#cursor.peek().end : undefined; + const end = whole ? undefined : this.#cursor.peek().end; const timeline = this.#state.timeline; let presentation: Drift["presentation"]; const info = this.#state.info.peek(); @@ -3132,7 +3134,7 @@ export class Subscriber { const scaleless = info !== undefined && info.timescale == null; for (let i = (end === undefined ? timeline.length : timelineIndex(timeline, end)) - 1; i >= 0; i--) { const group = timeline[i]; - if (hooks.groupFailed(group) || !this.#judges(group.start)) continue; + if (hooks.groupFailed(group) || !this.#judges(group.start, whole)) continue; if (scaleless) { if (!hooks.groupStarted(group)) continue; presentation = { key: group.start, at: Number(group.start) }; @@ -3152,6 +3154,19 @@ export class Subscriber { bounded: fresh !== undefined && requested >= fresh, presentation, end, + whole, + }; + } + + // {@link #drift} as a fetch judges its group, against the whole track, under the fetch's own + // budget in milliseconds in place of this reader's, still capped by the track's max age. + #driftWithin(budget: number): Drift { + const drift = this.#drift(true); + const fresh = this.#state.info.peek()?.maxAge?.asMillis(); + return { + ...drift, + budget: fresh === undefined ? budget : Math.min(budget, fresh), + bounded: fresh !== undefined && budget >= fresh, }; } @@ -3163,30 +3178,35 @@ export class Subscriber { // last timestamp says where it starts presenting, not where it ends. A group whose header // landed without a frame is not content yet, so the next one is the bound; an unstamped // successor leaves the reach unbounded. - #successor(key: bigint, end?: bigint): GroupConsumer | undefined { - return this.#after(key, end, hooks.groupStarted); + #successor(key: bigint, end?: bigint, whole?: boolean): GroupConsumer | undefined { + return this.#after(key, end, hooks.groupStarted, whole); } // The group after `key` that starts its wall clock: like {@link #successor}, but // counting a group before its first frame. Its header arrived, so a relay ages the group // before it as the origin does, even if its first frame never comes. - #arrival(key: bigint, end?: bigint): GroupConsumer | undefined { - return this.#after(key, end, () => true); + #arrival(key: bigint, end?: bigint, whole?: boolean): GroupConsumer | undefined { + return this.#after(key, end, () => true, whole); } // Whether group `key` counts toward the drift edge: inside the window, or anywhere for a - // fetch. - #judges(key: bigint): boolean { - return this.#fetchBudget !== undefined || this.#window.contains(key); + // fetch or when judging the `whole` track. + #judges(key: bigint, whole = this.#fetchBudget !== undefined): boolean { + return whole || this.#window.contains(key); } // The first servable group after `key` below `end` that `counts`. - #after(key: bigint, end: bigint | undefined, counts: (group: GroupConsumer) => boolean): GroupConsumer | undefined { + #after( + key: bigint, + end: bigint | undefined, + counts: (group: GroupConsumer) => boolean, + whole?: boolean, + ): GroupConsumer | undefined { const timeline = this.#state.timeline; for (let i = timelineIndex(timeline, key + 1n); i < timeline.length; i++) { const successor = timeline[i]; if (end !== undefined && successor.start >= end) break; - if (hooks.groupFailed(successor) || !this.#judges(successor.start)) continue; + if (hooks.groupFailed(successor) || !this.#judges(successor.start, whole)) continue; if (counts(successor)) return successor; } return undefined; @@ -3220,7 +3240,7 @@ export class Subscriber { // from another copy, or outliving this subscriber. Once closed, only the wall clock judges // it, from the arrivals kept at close. #staleAt(key: bigint, drift: Drift, wake = false, held?: Superseded): boolean { - const arrival = this.#arrivals ? undefined : this.#arrival(key, drift.end); + const arrival = this.#arrivals ? undefined : this.#arrival(key, drift.end, drift.whole); let arrived = this.#arrivals ? this.#keptSupersededAt(key, drift, held) : this.#supersededAt(arrival, drift, held); @@ -3234,7 +3254,7 @@ export class Subscriber { // A closed subscriber keeps no timeline to bound the reach with. if (this.#arrivals) return false; - const reach = this.#reach(key, drift.end); + const reach = this.#reach(key, drift.end, drift.whole); return ( drift.presentation !== undefined && drift.presentation.key > key && @@ -3262,10 +3282,10 @@ export class Subscriber { // The furthest presentation time, in milliseconds, group `key` could still reach: its own // end once finished whole, else where its immediate successor below `end` begins, undefined // when nothing proves where it stops. Mirrors the Rust `TrackState::reach`. - #reach(key: bigint, end: bigint | undefined): number | undefined { + #reach(key: bigint, end: bigint | undefined, whole?: boolean): number | undefined { const own = this.#held(key)?.end; if (own !== undefined) return this.#presented(own); - const successor = this.#successor(key, end); + const successor = this.#successor(key, end, whole); if (!successor) return undefined; const info = this.#state.info.peek(); if (info !== undefined && info.timescale == null) return this.#presented(successor.start); @@ -4291,10 +4311,11 @@ export class Subscriber { (subscriber.#state.closed.peek() !== undefined || subscriber.#complete()) && !hooks.hasUnreadGroup(subscriber, start, end, delivered); hooks.awaitsFill = (subscriber) => subscriber.#fillWait; - hooks.staleAt = (subscriber, key) => { + hooks.staleAt = (subscriber, key, budget) => { const held: Superseded = {}; + const drift = budget === undefined ? () => subscriber.#drift() : () => subscriber.#driftWithin(budget); return { - expired: () => subscriber.#staleAt(key, subscriber.#drift(), true, held), + expired: () => subscriber.#staleAt(key, drift(), true, held), changed: subscriber.#expiryChanged(), }; }; diff --git a/quest/m0/js-relayed-fetch-budget.md b/quest/m0/js-relayed-fetch-budget.md deleted file mode 100644 index 64923fa33e..0000000000 --- a/quest/m0/js-relayed-fetch-budget.md +++ /dev/null @@ -1,24 +0,0 @@ -# [M] A JS relay judges a relayed FETCH by its budget - -## Goal - -A JS publisher serving a lite FETCH for a broadcast it consumes over the wire -(through a `Front`) resets the response with OLD once the group goes stale -while the reply waits on flow control or its acknowledgement, as it already -does for a broadcast it produces and as a Rust relay does. - -## Plan - -Found reviewing [moq-dev/moq#9140](https://github.com/moq-dev/moq/pull/9140). -`js/net/src/lite/publisher.ts` `#serveFetch` judges the group with `GivenUp`, -but a group from `Front.fetchGroup` comes from the wire -(`lite/subscriber.ts` `fetchGroup`) with no expiry attached, so only an -upstream reset or failure gives it up. Once the upstream reply is -acknowledged, nothing judges the downstream one. Rust has no gap: a relayed -fetch fills the track cache, whose policy judges it. - -Recommendation: attach an expiry judged by the route copy that holds the -track, as the routed draft-22 fill does through `ResumeSource.staleAt`, -without opening a subscription: a fetch-only relay must not start pulling the -track upstream. With no copy subscribed, nothing newer is known locally, which -matches Rust's cache.