From ed66f9760c4a8daa38b12e9207ebd2ee96819e29 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 25 Oct 2026 01:53:56 -0700 Subject: [PATCH 1/4] chore(quest): claim quest/m1/resume-floor.md Quest-Claim: 13c2eb48434f6bc9 From 95ea6b36e0bb4b54bf738be7a4805a3faf882d10 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 25 Oct 2026 02:09:53 -0700 Subject: [PATCH 2/4] fix(net): a lowered resume floor backfills from the serving route Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/model/resume.rs | 146 +++++++++++++++++++++++++++------ rs/moq-net/src/model/track.rs | 6 +- 2 files changed, 125 insertions(+), 27 deletions(-) diff --git a/rs/moq-net/src/model/resume.rs b/rs/moq-net/src/model/resume.rs index 2db144d166c..2787f99ee42 100644 --- a/rs/moq-net/src/model/resume.rs +++ b/rs/moq-net/src/model/resume.rs @@ -17,6 +17,11 @@ //! only once nothing it replaced may still deliver below that end. Datagrams are ephemeral, //! so no copy is kept for them: a reader that never asked for a group keeps none. //! +//! A new copy is asked from where the reader got to, so it never has the groups below the +//! reader's local floor that the copies it replaced cached. Lowering that floor asks the +//! newest route for them through a backfill: another copy of that route, bounded to the +//! groups the floor newly covers, and kept like a replaced copy. +//! //! A group carries on across the switch through its [`Recover`]: once its copy stalls while //! a newer route serves, it continues from the serving route's copy of the same group at the //! same frame (and byte), found in that copy's cache or fetched from it. Once its copy fails, @@ -687,8 +692,9 @@ impl Subscriber { } /// Assign the local read floor and exclusive cap; see [`track::Subscriber::with_range`]. - pub(super) fn set_range(&mut self, start: u64, end: Option) { - self.reader().set_range(start, end) + /// `delivered` says which groups a lowered floor newly owes. + pub(super) fn set_range(&mut self, start: u64, end: Option, delivered: &Delivered) { + self.reader().set_range(start, end, delivered) } /// Whether any subscribed copy still has a group matching `unread`. @@ -748,11 +754,11 @@ impl Subscriber { } struct Candidate { - generation: u64, sequence: u64, - /// A nested reader may sync a route swap before its caller consumes this - /// candidate. Keep its exact copy alive until that commit. - _lease: Arc<()>, + /// Its copy's lease, which names that copy: one route can back several. A nested reader + /// may sync a route swap before its caller consumes this candidate, so it also keeps + /// that exact copy alive until that commit. + lease: Arc<()>, } /// Exact identities within the reader's budget. The last delivery never ages until @@ -811,7 +817,8 @@ struct Reader { mirrored: Subscription, /// The route generation last read. generation: Option, - /// Oldest first: the last one is the serving route's, when it is subscribed. + /// Oldest first, except that a backfill goes before the copy of the route it backfills: the + /// last one is the serving route's own, when it is subscribed. copies: Vec, /// The newest group handed out: where a new copy is asked to start. newest: Option, @@ -956,16 +963,10 @@ impl Reader { copy.replaced = true; } // Returning to a route reuses its subscription and leases, including an older - // group's in-flight tail. A fresh copy would replay it and retain one per flap. - if let Some(index) = self.copies.iter().position(|copy| copy.track.same_channel(&track)) { + // group's in-flight tail. A fresh copy would replay it and retain one per flap. The + // newest is the route's own copy, not a backfill of it. + if let Some(index) = self.copies.iter().rposition(|copy| copy.track.same_channel(&track)) { let mut copy = self.copies.remove(index); - if let Some(candidate) = self - .peeked - .as_mut() - .filter(|candidate| candidate.generation == copy.generation) - { - candidate.generation = generation; - } copy.generation = generation; copy.replaced = false; copy.until = None; @@ -1147,9 +1148,9 @@ impl Reader { /// copies it replaced just below it: what they hold under it may be groups the new route /// never has, and what is at or above it the new route delivers. Never below a group /// already handed out. A group it replays, already handed out, bounds nothing: the - /// replaced copies may still hold the next. + /// replaced copies may still hold the next. Nor does a backfill of the serving route. fn observe(&mut self, index: usize, sequence: u64) { - if Some(self.copies[index].generation) != self.generation { + if self.copies[index].replaced || Some(self.copies[index].generation) != self.generation { return; } let bound = self.newest.max(sequence.checked_sub(1)); @@ -1235,7 +1236,7 @@ impl Reader { let index = self .copies .iter() - .position(|copy| copy.generation == candidate.generation) + .position(|copy| Arc::ptr_eq(©.lease, &candidate.lease)) .expect("the candidate's lease retains its copy"); let Sub::Ready(sub) = &mut self.copies[index].sub else { unreachable!() @@ -1331,9 +1332,8 @@ impl Reader { } if lowest.as_ref().is_none_or(|lowest| sequence <= lowest.sequence) { lowest = Some(Candidate { - generation: self.copies[index].generation, sequence, - _lease: self.copies[index].lease.clone(), + lease: self.copies[index].lease.clone(), }); } break; @@ -1562,15 +1562,63 @@ impl Reader { /// Assign the local floor and cap. A copy still waiting on its info takes them when it /// resolves; one already reading has to be moved, or a group it skipped stays skipped. - fn set_range(&mut self, start: u64, end: Option) { + fn set_range(&mut self, start: u64, end: Option, delivered: &Delivered) { self.peeked = None; - self.groups = (start, end); + let passed = std::mem::replace(&mut self.groups, (start, end)).0; for copy in &mut self.copies { let start = copy.start(start); if let Sub::Ready(sub) = &mut copy.sub { sub.set_range((Bound::Included(start), end.map_or(Bound::Unbounded, Bound::Excluded))); } } + self.backfill(start..passed, delivered); + } + + /// Ask the newest copy's route for the groups in `lowered` under that copy's resume point, + /// which a lowered floor newly covers. The copies that cached them may be gone, and that + /// copy never asked for them, so a bounded copy of the same route asks for just those. + fn backfill(&mut self, lowered: std::ops::Range, delivered: &Delivered) { + let Some(end) = self.copies.last().and_then(|newest| newest.floor) else { + return; + }; + let lowered = lowered.start..lowered.end.min(end); + // An ordered reader never goes back, nor does any reader past its budget. + if delivered.covers(lowered.clone()) { + return; + } + let newest = self.copies.last().expect("checked above"); + let (generation, track) = (newest.generation, newest.track.clone()); + // A floor lowered again asks once. + if self.copies.iter().any(|copy| { + copy.track.same_channel(&track) + && copy.floor.is_some_and(|floor| floor <= lowered.start) + && copy.end().is_none_or(|end| end >= lowered.end) + }) { + return; + } + // Resolved as the reader first had them: the newest copy's resolution starts at its + // resume point. + let resolved = self.window().resolved(); + let floor = Some(lowered.start); + let wire = self.mirrored.clamped(floor, Some(lowered.end), &resolved); + let copy = Copy { + generation, + sub: Sub::Pending(track.subscribe(wire)), + floor, + from: self.mirrored.ranges.clone(), + resolved, + // Bounded from the start: everything it may deliver is older than what the reader + // already read, so it is waited for no longer than the reader's budget. + replaced: true, + until: Some(lowered.end.checked_sub(1)), + since: Some(track.now()), + track, + done: None, + datagrams_done: None, + lease: Arc::new(()), + }; + // The last copy stays the newest route's own. + self.copies.insert(self.copies.len() - 1, copy); } #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] @@ -1883,13 +1931,14 @@ impl Recover { self.copy = replacement.copy.clone(); self.handoff = replacement.group.handoff(); // A later switch must keep this copy subscribed while the recovered group - // still reads it, just like a group handed out from that copy directly. + // still reads it, just like a group handed out from that copy directly. The newest of + // the generation is the route's own copy, not a backfill of it. self.lease = self.reader.as_ref().and_then(Weak::upgrade).and_then(|reader| { let reader = reader.lock().unwrap_or_else(PoisonError::into_inner); reader .copies .iter() - .find(|copy| copy.generation == replacement.generation) + .rfind(|copy| copy.generation == replacement.generation) .map(|copy| copy.lease.clone()) }); self.fetch = None; @@ -3087,6 +3136,53 @@ mod test { assert_eq!(drain(&mut sub, false), Vec::::new(), "nothing goes out twice"); } + /// Lowering a resumed reader's floor offers the groups below the old floor that only a + /// copy it already let go cached: the serving route is asked for just those, whether it + /// caches them or gets them once asked. An ordered reader never goes back, so it asks + /// for nothing. + #[test] + fn a_lowered_floor_asks_the_serving_route_for_a_released_copys_groups() { + for (cached, ordered) in [(true, false), (false, false), (true, true)] { + let case = format!("cached={cached}, ordered={ordered}"); + let routes = Producer::new(); + let logical = logical(&routes); + let a = copy(); + routes.serve(a.consume()); + let mut sub = subscribe(&logical, HOUR).with_range(4..); + for sequence in 0..6 { + write(&a, sequence); + } + assert_eq!(drain(&mut sub, ordered), [4, 5]); + + let b = copy(); + if cached { + for sequence in 0..6 { + write(&b, sequence); + } + } + routes.serve(b.consume()); + write(&b, 6); + assert_eq!(drain(&mut sub, ordered), [6]); + assert_eq!(copies(&routes), 1, "the replaced copy is let go: {case}"); + assert_eq!(b.subscription().unwrap().start(), Some(5)); + + let mut sub = sub.with_range(1..).with_range(4..).with_range(1..); + let asked = if ordered { 5 } else { 1 }; + assert_eq!(b.subscription().unwrap().start(), Some(asked), "{case}"); + assert_eq!(copies(&routes), if ordered { 1 } else { 2 }, "asked once: {case}"); + if !cached { + assert_eq!(drain(&mut sub, ordered), Vec::::new()); + for sequence in 1..4 { + write(&b, sequence); + } + } + let lowered: &[u64] = if ordered { &[] } else { &[1, 2, 3] }; + assert_eq!(drain(&mut sub, ordered), lowered, "{case}"); + write(&b, 7); + assert_eq!(drain(&mut sub, ordered), [7], "{case}"); + } + } + #[test] fn a_fresh_nested_reader_ends_after_its_outer_reader_already_passed_its_groups() { let routes = Producer::new(); diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index bbc5a44ea84..871523b5259 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -6896,7 +6896,9 @@ impl Subscriber { /// A local filter, not a request: it tells the publisher nothing, so groups outside it /// are still delivered and simply not returned. To change what is requested, set /// [`Subscription::ranges`] via [`Self::update`]. See [Local cursor vs wire - /// preference](Self#local-cursor-vs-wire-preference). + /// preference](Self#local-cursor-vs-wire-preference). One exception: on a track served + /// across route changes, lowering the floor asks the serving route again for the groups + /// it newly covers within those ranges, since the route that delivered them may be gone. pub fn with_range(mut self, groups: impl RangeBounds) -> Self { self.set_range(groups); self @@ -6912,7 +6914,7 @@ impl Subscriber { cursor.end_sequence = end; cursor.update_servable(); } - Inner::Resume(resume, _) => resume.set_range(start, end), + Inner::Resume(resume, _) => resume.set_range(start, end, &self.delivered), } self.largest.bounds_moved(); } From 3dd323c30eb5d31fb76ef13f7f03c2a5ca16df19 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 25 Oct 2026 02:20:52 -0700 Subject: [PATCH 3/4] fix(net): mirror the resume floor backfill in js and finish the quest Co-Authored-By: Claude Opus 5.5 --- js/net/src/resume.test.ts | 62 ++++++++++++++++++++++++++++++++++ js/net/src/resume.ts | 70 ++++++++++++++++++++++++++++++++++----- js/net/src/track.ts | 4 ++- quest/m1/README.md | 1 - quest/m1/resume-floor.md | 31 ----------------- 5 files changed, 126 insertions(+), 42 deletions(-) delete mode 100644 quest/m1/resume-floor.md diff --git a/js/net/src/resume.test.ts b/js/net/src/resume.test.ts index 5270b05224b..a0488f4160a 100644 --- a/js/net/src/resume.test.ts +++ b/js/net/src/resume.test.ts @@ -2341,6 +2341,68 @@ test.each(["lands", "expired"])( }, ); +// Lowering a resumed reader's floor offers the groups below the old floor that only a copy it +// already let go cached: the serving route is asked for just those, whether it caches them or +// gets them once asked. An ordered reader never goes back, so it asks for nothing. +test.each([ + [true, false], + [false, false], + [true, true], +])( + "a lowered floor asks the serving route for a released copy's groups (cached=%p, ordered=%p)", + async (cached, ordered) => { + const front = new Front(); + const a = new BroadcastProducer(); + const b = new BroadcastProducer(); + const ta = copy(a); + const tb = copy(b); + front.serve(a.consume()); + const sub = front.consumer.track("seq").subscribe({ maxDelay: Milli(3_600_000) }); + const inOrder = ordered ? sub.ordered() : undefined; + const read = () => { + const sequences: number[] = []; + const next = () => (inOrder ? inOrder.tryNextGroup() : sub.tryRecvGroup()); + for (let group = next(); group; group = next()) { + sequences.push(group.sequence); + group.close(); + } + return sequences; + }; + const asked = () => tb.producer.subscription.peek()?.groups?.start?.included; + try { + sub.withRange({ start: { included: 4 } }); + await settle(); + for (let sequence = 0; sequence < 6; sequence++) ta.write(sequence); + expect(read()).toEqual([4, 5]); + + if (cached) for (let sequence = 0; sequence < 6; sequence++) tb.write(sequence); + front.serve(b.consume()); + await settle(); + tb.write(6); + expect(read()).toEqual([6]); + await settle(); + expect(ta.producer.demand().wanted.peek()).toBeUndefined(); + expect(asked()).toBe(5); + + sub.withRange({ start: { included: 1 } }); + await settle(); + expect(asked()).toBe(ordered ? 5 : 1); + if (!cached) { + expect(read()).toEqual([]); + for (let sequence = 1; sequence < 4; sequence++) tb.write(sequence); + } + expect(read()).toEqual(ordered ? [] : [1, 2, 3]); + tb.write(7); + expect(read()).toEqual([7]); + } finally { + sub.close(); + front.consumer.close(); + a.close(); + b.close(); + } + }, +); + test("a datagram below the group floor does not keep a finite track's copy", async () => { const front = new Front(); const a = new BroadcastProducer(); diff --git a/js/net/src/resume.ts b/js/net/src/resume.ts index 7a7c6d0cbf8..4d004f37bac 100644 --- a/js/net/src/resume.ts +++ b/js/net/src/resume.ts @@ -17,6 +17,11 @@ * yet get it). Nothing under the bound is waited for past the reader's budget. Datagrams are * ephemeral, so no copy is kept for them: a reader that never asked for a group keeps none. * + * A new copy is asked from where the reader got to, so it never has the groups below the reader's + * local floor that the copies it replaced cached. Lowering that floor asks the newest route for + * them through a backfill: another copy of that route, bounded to the groups the floor newly + * covers, and kept like a replaced copy. + * * A group carries on across the switch through its {@link Recover}: once its copy stalls while a * newer route serves, it continues from the serving route's copy of the same group at the same * frame, found in that copy's cache or fetched from it. Once its copy fails, any other copy still @@ -271,8 +276,13 @@ class Reader implements ResumeSource { #shell: ResumeShell; /** The route generation last read. */ #generation?: number; - /** Oldest first: the last one is the serving route's, when it is subscribed. */ + /** + * Oldest first, except that a backfill goes before the copy of the route it backfills: the last + * one is the serving route's own, when it is subscribed. + */ #copies: Copy[] = []; + /** The cursor start the copies were last bounded at: a lower one asks for a backfill. */ + #start: number; /** The newest group handed out: where a new copy is asked to start. */ #newest?: number; /** The last datagram handed out, which never ages until another supersedes it. */ @@ -315,6 +325,7 @@ class Reader implements ResumeSource { this.route = route; this.#shell = shell; this.#record = record; + this.#start = shell.cursor.peek().start; route.readers.add(this); this.#dispose.push( shell.subscription.subscribe(() => { @@ -322,6 +333,9 @@ class Reader implements ResumeSource { }), shell.cursor.subscribe(() => { for (const copy of this.#copies) this.#bound(copy); + const passed = this.#start; + this.#start = shell.cursor.peek().start; + if (this.#start < passed) this.#backfill(this.#start, passed); if (this.#ended) this.#letGo(this.#delivered); }), ); @@ -355,8 +369,9 @@ class Reader implements ResumeSource { // group they get meanwhile may be one the new route never has. See #observe. for (const copy of this.#copies) copy.replaced = true; // Cloned handles share closed, so a returning route reuses its subscription and - // leases rather than replaying its cache and retaining another copy per flap. - const index = this.#copies.findIndex((copy) => copy.source.from.closed === source.from.closed); + // leases rather than replaying its cache and retaining another copy per flap. The newest + // is the route's own copy, not a backfill of it. + const index = this.#copies.findLastIndex((copy) => copy.source.from.closed === source.from.closed); if (index !== -1) { const [copy] = this.#copies.splice(index, 1); source.retain(); @@ -390,12 +405,12 @@ class Reader implements ResumeSource { }); } - /** Read `copy` as the newest one, recording the properties it commits. */ - #add(copy: Copy): void { + /** Read `copy` as the newest one, or at `index`, recording the properties it commits. */ + #add(copy: Copy, index = this.#copies.length): void { const { source } = copy; source.retain(); this.#bound(copy); - this.#copies.push(copy); + this.#copies.splice(index, 0, copy); const shell = this.#shell; const record = this.#record; copy.sub.info().then( @@ -467,14 +482,50 @@ class Reader implements ResumeSource { }); } + /** + * Ask the newest copy's route for the groups from `start` up to `passed` under that copy's + * resume point, which a lowered floor newly covers. The copies that cached them may be gone, + * and that copy never asked for them, so a bounded copy of the same route asks for just those. + */ + #backfill(start: number, passed: number): void { + const newest = this.#copies.at(-1); + if (this.#closed || this.#ended || newest?.floor === undefined) return; + const end = Math.min(passed, newest.floor); + // An ordered reader never goes back, nor does any reader past its budget. + if (this.#delivered.covers(start, end)) return; + // A floor lowered again asks once. + const closed = newest.source.from.closed; + const asked = (copy: Copy) => + copy.source.from.closed === closed && + copy.floor !== undefined && + copy.floor <= start && + (copyEnd(copy) ?? Number.POSITIVE_INFINITY) >= end; + if (this.#copies.some(asked)) return; + const backfill = { floor: start, until: end - 1 }; + this.#add( + { + generation: newest.generation, + source: newest.source, + sub: subscribe(newest.source.wire, this.route.name, this.#wire(backfill)), + ...backfill, + // Bounded from the start: everything it may deliver is older than what the reader + // already read, so it is waited for no longer than the reader's budget. + replaced: true, + since: now(), + lease: 0, + }, + this.#copies.length - 1, + ); + } + /** Wake parked reads, so they look again and let go of what nothing needs. */ wake(): void { this.#changed.update((n) => n + 1); } - /** The reader's copy of the route at `generation`, if it subscribed one. */ + /** 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.find((copy) => copy.generation === generation); + return this.#copies.findLast((copy) => copy.generation === generation); } /** The copies other than `except` whose track still holds group `sequence` unfailed, newest first. */ @@ -492,9 +543,10 @@ class Reader implements ResumeSource { * just below it: what they hold under it may be groups the new route never has, and what * is at or above it the new route delivers. Never below a group already handed out. A group * it replays, already handed out, bounds nothing: the replaced copies may still hold the next. + * Nor does a backfill of the serving route. */ #observe(copy: Copy, sequence: number): void { - if (copy.generation !== this.#generation) return; + if (copy.replaced || copy.generation !== this.#generation) return; const bound = Math.max(this.#newest ?? -1, sequence - 1); for (const replaced of this.#copies) { if (replaced === copy || !replaced.replaced || replaced.until !== undefined) continue; diff --git a/js/net/src/track.ts b/js/net/src/track.ts index c4f707e98e1..bff4e64570d 100644 --- a/js/net/src/track.ts +++ b/js/net/src/track.ts @@ -2302,7 +2302,9 @@ export class Subscriber { * omitted end removes the cap. Lowering the floor or raising the cap offers the groups it * newly covers that the track still caches and this reader never handed out; a group is * never handed out twice. A local filter, not a request: it leaves the wire subscription - * alone. {@link largest} reports within these bounds. + * alone. One exception: on a track served across route changes, lowering the floor asks the + * serving route again for the groups it newly covers within the subscription's groups, since + * the route that delivered them may be gone. {@link largest} reports within these bounds. */ withRange(groups: Groups): this { const { start, end } = groupBounds(groups); diff --git a/quest/m1/README.md b/quest/m1/README.md index 9ad0bfc1971..b121eb6abc5 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -141,7 +141,6 @@ Catalog HLS field. - [JS reload config](/quest/m1/js-reload-config.md) - `@moq/net` reload takes Rust's `healthy` backoff and no ignored `extensions` - [TS fidelity and recovery](/quest/m1/ts-reliability/README.md) - both modes have explicit profiles, automated validation, loss tests, and a dedicated guide - [JS resume reports drops](/quest/m1/resume-drops.md) - a routed JS subscriber reports its copies' dropped groups, so publishers forward SUBSCRIBE_DROP -- [Lowered resume floor](/quest/m1/resume-floor.md) - lowering a resumed reader's floor re-offers groups only a released copy cached - [WebGPU on Safari](/quest/m1/webgpu-safari.md) - the WebGPU renderer is verified on Safari 26 for macOS and iOS - [JSON encoder options without a downcast](/quest/m1/json-encoder-options.md) - moq-mux's `json_snapshot` takes its `deltas` switch through a typed path any custom catalog entry can use, not an `Any` downcast - [CI housekeeping](/quest/m1/ci-housekeeping.md) - validate queue nextest at 24 threads and remove the actionlint queue ignore after its release diff --git a/quest/m1/resume-floor.md b/quest/m1/resume-floor.md deleted file mode 100644 index a31c0304b8c..00000000000 --- a/quest/m1/resume-floor.md +++ /dev/null @@ -1,31 +0,0 @@ -# [S] A lowered resume floor re-offers a released copy's groups - -## Goal - -Lowering a resumed reader's floor with `with_range` (JS `withRange`) offers -every group below the old floor that some route still caches and the reader -never read, as it does for a direct reader. Today, in Rust, a reader that -switches routes while its floor is high lets go of the replaced copy that -cached the lower groups, so a later lowering re-offers only what the serving -copy holds: `Copy::start` clamps the requested floor to that copy's resume -point. - -## Plan - -Found by Codex on [moq-dev/moq#6138](https://github.com/moq-dev/moq/pull/6138), -which made lowering a floor assign. Its Rust test covers one copy only. - -Open decision, to settle before implementing: - -- Recommended: once the floor drops below a released copy's groups, ask the - serving route for them on demand, rather than keeping every replaced copy - alive in case the floor drops later, which holds memory for a lowering that - may never come. -- Alternative: narrow the `with_range` contract to the copies the reader still - holds, and document it. - -Check the JS resume reader for the same gap, and cover both with a two-copy -test: switch routes with a high floor, release the old copy, lower the floor, -and expect the groups only it cached. - -Public API: behavior only. Wire: none. From 0b68937aec547294eb06def3bf377a2152459421 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 25 Oct 2026 12:44:11 -0700 Subject: [PATCH 4/4] test(js): drive the lowered-floor test on a manual clock Co-Authored-By: Claude Opus 5.5 --- js/net/src/resume.test.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/net/src/resume.test.ts b/js/net/src/resume.test.ts index d9c80383581..9218d0e658f 100644 --- a/js/net/src/resume.test.ts +++ b/js/net/src/resume.test.ts @@ -2508,6 +2508,8 @@ test.each([ ])( "a lowered floor asks the serving route for a released copy's groups (cached=%p, ordered=%p)", async (cached, ordered) => { + const clock = new Manual(); + const installed = clock.install(); const front = new Front(); const a = new BroadcastProducer(); const b = new BroadcastProducer(); @@ -2528,21 +2530,21 @@ test.each([ const asked = () => tb.producer.subscription.peek()?.groups?.start?.included; try { sub.withRange({ start: { included: 4 } }); - await settle(); + await clock.advance(Nano.zero); for (let sequence = 0; sequence < 6; sequence++) ta.write(sequence); expect(read()).toEqual([4, 5]); if (cached) for (let sequence = 0; sequence < 6; sequence++) tb.write(sequence); front.serve(b.consume()); - await settle(); + await clock.advance(Nano.zero); tb.write(6); expect(read()).toEqual([6]); - await settle(); + await clock.advance(Nano.zero); expect(ta.producer.demand().wanted.peek()).toBeUndefined(); expect(asked()).toBe(5); sub.withRange({ start: { included: 1 } }); - await settle(); + await clock.advance(Nano.zero); expect(asked()).toBe(ordered ? 5 : 1); if (!cached) { expect(read()).toEqual([]); @@ -2556,6 +2558,7 @@ test.each([ front.consumer.close(); a.close(); b.close(); + installed.close(); } }, );