diff --git a/js/net/api/index.api.md b/js/net/api/index.api.md index 4b49d9878f9..f3c73cf771b 100644 --- a/js/net/api/index.api.md +++ b/js/net/api/index.api.md @@ -853,6 +853,7 @@ type ReloadDelay = { initial?: Milli; multiplier?: number; max?: Milli; + healthy?: Milli; timeout?: Milli; }; diff --git a/js/net/src/connection/migrate.test.ts b/js/net/src/connection/migrate.test.ts index 5c4c1a2485f..a6fb2e0988b 100644 --- a/js/net/src/connection/migrate.test.ts +++ b/js/net/src/connection/migrate.test.ts @@ -423,8 +423,8 @@ test.each([ url, websocket: { enabled: false }, goaway: { handover }, - // Every session outlives the initial delay, so the immediate-redirect damping never applies. - delay: { initial: Milli(10), multiplier: 4, max: Milli(1000) }, + // Every session outlives the healthy bar, so the immediate-redirect damping never applies. + delay: { initial: Milli(10), multiplier: 4, max: Milli(1000), healthy: Milli(10) }, }); try { @@ -484,7 +484,7 @@ test("a redirect loop stops at the retry window", async () => { url, websocket: { enabled: false }, goaway: { handover }, - delay: { initial: Milli(10), multiplier: 4, max: Milli(1000), timeout: Milli(150) }, + delay: { initial: Milli(10), multiplier: 4, max: Milli(1000), healthy: Milli(10), timeout: Milli(150) }, }); try { @@ -510,7 +510,7 @@ test("a loop no faster than the capped delay migrates without backing off", asyn websocket: { enabled: false }, goaway: { handover }, // Each session lives exactly the cap, so it already redials no faster than the backoff would. - delay: { initial: Milli(10), max: life }, + delay: { initial: Milli(10), max: life, healthy: Milli(10) }, }); try { @@ -538,7 +538,7 @@ test("a one-way rolling restart migrates without backing off", async () => { try { await waitUntil(() => reload.status.peek() === "connected"); - // Outlive the initial delay so only loop detection could slow this down. + // Outlive the default healthy bar (1000ms) so only loop detection could slow this down. await clock.advance(Nano.fromMilli(Milli(1100))); await goaway(dials[0]?.server as WebTransport, moved.href); expect(await elapse(clock, () => dials.length === 2)).toBe(Milli(0)); @@ -557,13 +557,13 @@ test("repeated GOAWAYs back to the same place are restarts, not a loop", async ( websocket: { enabled: false }, goaway: { handover }, // Long enough that any backoff would be visible. - delay: { initial: Milli(300) }, + delay: { initial: Milli(300), healthy: Milli(300) }, }); try { for (let i = 1; i <= 3; i++) { await waitUntil(() => dials.length === i && reload.status.peek() === "connected"); - // Outlive the initial delay so only loop detection could slow this down. + // Outlive the healthy bar so only loop detection could slow this down. await clock.advance(Nano.fromMilli(Milli(350))); await goaway(dials[i - 1]?.server as WebTransport, ""); expect(await elapse(clock, () => dials.length === i + 1), `restart ${i}`).toBe(Milli(0)); @@ -573,3 +573,33 @@ test("repeated GOAWAYs back to the same place are restarts, not a loop", async ( installed.close(); } }); + +test("a peer restarting through immediate GOAWAYs escalates the backoff but never spends the window", async () => { + const clock = new Manual(); + const installed = clock.install(); + // Full delay every time, so the waits are exact. + const random = spyOn(Math, "random").mockReturnValue(1); + const { dials } = fleet(); + const reload = new Reload({ + url, + websocket: { enabled: false }, + goaway: { handover }, + // The waits add up to far more than the window, which a restart restarts after each one. + delay: { initial: Milli(10), multiplier: 2, max: Milli(1000), timeout: Milli(25) }, + }); + + try { + const waited: number[] = []; + for (let i = 1; i <= 4; i++) { + await waitUntil(() => dials.length === i && reload.status.peek() === "connected"); + await goaway(dials[i - 1]?.server as WebTransport, ""); + waited.push(await elapse(clock, () => dials.length === i + 1 || reload.error.peek() !== undefined)); + } + expect(waited).toEqual([10, 20, 40, 80]); + expect(reload.error.peek()).toBeUndefined(); + } finally { + reload.close(); + random.mockRestore(); + installed.close(); + } +}); diff --git a/js/net/src/connection/reload.test.ts b/js/net/src/connection/reload.test.ts index ab1934b07b3..febd5649673 100644 --- a/js/net/src/connection/reload.test.ts +++ b/js/net/src/connection/reload.test.ts @@ -17,7 +17,7 @@ import { wireOf } from "../wire.ts"; import type { Established } from "./established.ts"; import { type AcceptProps, accept as acceptSession } from "./index.ts"; import { Connection, resetShared } from "./pool.ts"; -import { pumpAnnounced, Redirects, Reload, type ReloadProps } from "./reload.ts"; +import { pumpAnnounced, Redirects, Reload, type ReloadDelay, type ReloadProps } from "./reload.ts"; function accept(transport: WebTransport, url: URL, props: Omit = {}) { return acceptSession({ transport, url, ...props }); @@ -1166,36 +1166,159 @@ test("an attempt that outlives the connect timeout is retried after the backoff" } }); -test("attempts that keep timing out give up at the retry window with ConnectTimeout", async () => { +// Every attempt hangs until its 30 ms connect timeout. The window counts from the first dial, as +// moq-tokio's does, and no attempt starts once it has passed. +const windows: [string, ReloadDelay, number, number][] = [ + // Dials at 0, 40, and 80; the last runs past the window and gives up when it fails. + ["an attempt under way finishes past the window", { initial: Milli(10), timeout: Milli(100) }, 110, 3], + // The first failure at 30 ms leaves 30 ms, less than the 50 ms wait, so it gives up at the deadline. + ["a wait that reaches the deadline gives up there", { initial: Milli(50), timeout: Milli(60) }, 60, 1], +]; +for (const [name, delay, gaveUp, dials] of windows) { + test(`retry window: ${name}`, async () => { + const clock = new Manual(); + const installed = clock.install(); + // Full delay every time, so the waits are exact. + const random = spyOn(Math, "random").mockReturnValue(1); + const warned = spyOn(console, "warn").mockImplementation(() => {}); + const url = new URL("https://relay.example/room"); + const plan = dialPlan(() => "hang", url); + const reload = new Reload({ + url, + websocket: { enabled: false }, + timeout: Milli(30), + delay: { multiplier: 1, max: Milli(1000), ...delay }, + }); + try { + await waitUntil(() => plan.dials() === 1); + expect(await elapse(clock, () => reload.error.peek() !== undefined)).toBe(gaveUp); + expect(reload.error.peek()).toBeInstanceOf(ConnectTimeout); + expect(plan.dials()).toBe(dials); + expect(plan.hungCloses()).toBe(plan.dials()); + } finally { + reload.close(); + plan.restore(); + warned.mockRestore(); + random.mockRestore(); + installed.close(); + } + }); +} + +test("an invalid timeout is refused when the loop is built, not by every attempt", () => { + for (const timeout of [-1, Number.NaN, Number.POSITIVE_INFINITY]) { + expect(() => new Reload({ url: new URL("https://example.com/"), timeout: timeout as Milli })).toThrow( + RangeError, + ); + } +}); + +// Each session lives 100 ms, so the backoff between them shows how `healthy` scores its end and +// how `max` caps the delay, matching moq-tokio's `connect.backoff`. +const backoffs: [string, ReloadDelay, number[]][] = [ + // Past `initial` but short of the default bar, so each end is a failed attempt. + ["a session short of the default healthy bar escalates", {}, [10, 20, 40]], + ["a session past the healthy bar resets", { healthy: Milli(50) }, [10, 10, 10]], + [ + "a zero max leaves the delay uncapped", + { initial: Milli(1000), multiplier: 4, max: Milli(0) }, + [1000, 4000, 16000], + ], + ["a max below initial caps the first delay too", { max: Milli(5) }, [5, 5, 5]], + ["a zero multiplier keeps the delay constant", { multiplier: 0 }, [10, 10, 10]], + ["a fractional multiplier below 1 keeps the delay constant", { multiplier: 0.5 }, [10, 10, 10]], +]; +for (const [name, delay, gaps] of backoffs) { + test(`backoff: ${name}`, async () => { + const clock = new Manual(); + const installed = clock.install(); + // Full delay every time, so the waits are exact. + const random = spyOn(Math, "random").mockReturnValue(1); + const warned = spyOn(console, "warn").mockImplementation(() => {}); + const original = globalThis.WebTransport; + const url = new URL("https://relay.example/room"); + const servers: Promise<{ abort(): void }>[] = []; + globalThis.WebTransport = function StubWebTransport() { + const pair = createMockTransportPair(Lite.ALPN_06); + servers.push(accept(pair.server, url)); + return pair.client; + } as unknown as typeof WebTransport; + const reload = new Reload({ + url, + websocket: { enabled: false }, + delay: { initial: Milli(10), multiplier: 2, max: Milli(1000), ...delay }, + }); + try { + const waited: number[] = []; + for (let session = 0; session < gaps.length; session++) { + await waitUntil(() => reload.status.peek() === "connected"); + await clock.advance(Nano.fromMilli(Milli(100))); + (await servers[session])?.abort(); + waited.push(await elapse(clock, () => servers.length === session + 2)); + } + expect(waited).toEqual([...gaps]); + } finally { + reload.close(); + globalThis.WebTransport = original; + warned.mockRestore(); + random.mockRestore(); + installed.close(); + } + }); +} + +// The delay after the second failure, 1e601 ms, overflows; it saturates, as Rust's Duration +// does, rather than failing the loop. The 1e301 ms wait itself is never fired: at that +// instant a 100 ms poll no longer advances the clock. +test("backoff: an uncapped delay saturates instead of overflowing", async () => { const clock = new Manual(); const installed = clock.install(); + const warned = spyOn(console, "warn").mockImplementation(() => {}); + const failed = spyOn(console, "error"); + const original = globalThis.WebTransport; const url = new URL("https://relay.example/room"); - const plan = dialPlan(() => "hang", url); + const servers: Promise<{ abort(): void }>[] = []; + globalThis.WebTransport = function StubWebTransport() { + const pair = createMockTransportPair(Lite.ALPN_06); + servers.push(accept(pair.server, url)); + return pair.client; + } as unknown as typeof WebTransport; const reload = new Reload({ url, websocket: { enabled: false }, - timeout: Milli(30), - delay: { initial: Milli(10), multiplier: 1, max: Milli(10), timeout: Milli(100) }, + delay: { initial: Milli(10), multiplier: 1e300, max: Milli(0) }, }); try { - await waitUntil(() => plan.dials() === 1); - const waited = await elapse(clock, () => reload.error.peek() !== undefined); - // The window starts at the first failure (30 ms) and is checked at each failure after - // it, so giving up comes up to one attempt after the window. - expect(waited).toBeGreaterThanOrEqual(130); - expect(waited).toBeLessThan(170); - expect(reload.error.peek()).toBeInstanceOf(ConnectTimeout); - expect(plan.hungCloses()).toBe(plan.dials()); + for (let session = 0; session < 2; session++) { + await waitUntil(() => reload.status.peek() === "connected"); + (await servers[session])?.abort(); + if (session === 0) await elapse(clock, () => servers.length === 2); + } + await waitUntil(() => reload.status.peek() === "disconnected"); + for (let i = 0; i < 10; i++) await settle(); + expect(failed).not.toHaveBeenCalled(); + expect(reload.error.peek()).toBeUndefined(); } finally { reload.close(); - plan.restore(); + globalThis.WebTransport = original; + failed.mockRestore(); + warned.mockRestore(); installed.close(); } }); -test("an invalid timeout is refused when the loop is built, not by every attempt", () => { - for (const timeout of [-1, Number.NaN, Number.POSITIVE_INFINITY]) { - expect(() => new Reload({ url: new URL("https://example.com/"), timeout: timeout as Milli })).toThrow( +test("a delay field with no meaning is refused when the loop is built", () => { + const bad = [-1, Number.NaN, Number.POSITIVE_INFINITY] as Milli[]; + const invalid: ReloadDelay[] = [ + // Zero would count every session as healthy. + { healthy: Milli(0) }, + // Zero `max` is uncapped and zero `timeout` unlimited, so infinity has no spelling here. + ...bad.flatMap((value) => [{ initial: value }, { max: value }, { healthy: value }, { timeout: value }]), + { multiplier: Number.NaN }, + { multiplier: Number.POSITIVE_INFINITY }, + ]; + for (const delay of invalid) { + expect(() => new Reload({ url: new URL("https://example.com/"), delay }), JSON.stringify(delay)).toThrow( RangeError, ); } diff --git a/js/net/src/connection/reload.ts b/js/net/src/connection/reload.ts index 849f663417f..7bdb9cee285 100644 --- a/js/net/src/connection/reload.ts +++ b/js/net/src/connection/reload.ts @@ -30,27 +30,38 @@ import type { Probe, Stats } from "./stats.ts"; * rejection or a refused GOAWAY redirect stops the current URL sooner. A new URL or a * disable/re-enable starts another sequence. * - * A GOAWAY off a session that outlived {@link ReloadDelay.initial} migrates at once, unless it + * A GOAWAY off a session that outlived {@link ReloadDelay.healthy} migrates at once, unless it * sends the connection back to an endpoint that already redirected it elsewhere and the - * session lived less than {@link ReloadDelay.max}. Two peers redirecting to each other thus + * session lived less than {@link ReloadDelay.max} (or {@link ReloadDelay.healthy} when + * uncapped). Two peers redirecting to each other thus * wait out this backoff and count against the timeout. */ export type ReloadDelay = { - /** The delay before reconnecting (default: 1000ms). */ + /** The delay before reconnecting (default: 1000ms; zero retries at once). */ initial?: Milli; - /** The multiplier for the delay (default: 2). */ + /** The multiplier for the delay after each failure (default: 2; below 1 keeps it constant). */ multiplier?: number; - /** The maximum delay (default: 5000ms). */ + /** The maximum delay (default: 5000ms; zero leaves it uncapped). A cap below `initial` caps the first delay too. */ max?: Milli; + /** + * How long a session must stay up to count as healthy (default: 1000ms; must be positive). + * + * A healthy session's end resets the delay and the timeout. One that ends sooner is a + * failed attempt, so a peer that accepts and then drops every session still escalates the + * delay and exhausts the timeout. + */ + healthy?: Milli; + /** * Maximum total time to spend retrying the current URL before giving up - * (default: 0, unlimited). Resets after each successful connection outside a redirect loop, - * a URL change, or a disable/re-enable. It decides whether another attempt starts and never - * cuts one that is running, so giving up can take up to one attempt longer than the window; - * {@link ConnectProps.timeout} bounds each attempt. + * (default: 0, unlimited). Counts from the first dial, and restarts after a healthy session + * outside a redirect loop, a URL change, or a disable/re-enable. It decides whether another + * attempt starts and never cuts one that is running, so giving up can take up to one attempt + * longer than the window; {@link ConnectProps.timeout} bounds each attempt. A peer that + * restarts, draining each session with a GOAWAY naming no URI, restarts it too. */ timeout?: Milli; }; @@ -61,11 +72,11 @@ export type ReloadDelay = { * {@link ConnectProps.transport} is excluded: a supplied session is good for exactly one * connection, so the reconnect loop has nothing to reuse once that session drops. Call * {@link connect} directly when you have a session to hand over. Every attempt advertises - * the default {@link ConnectProps.implementation}. + * the default {@link ConnectProps.implementation} and {@link ConnectProps.extensions}. * * @internal */ -export type ReloadProps = Omit & { +export type ReloadProps = Omit & { /** A reload owns the abort signal for each connection attempt. */ signal?: never; @@ -98,9 +109,48 @@ const DEFAULT_DELAY: Required = { initial: Milli(1000), multiplier: 2, max: Milli(5000), + healthy: Milli(1000), timeout: Milli(0), }; +/** + * {@link ReloadDelay} resolved against its defaults, with the same meaning as moq-tokio's + * backoff. Throws a RangeError for a value that has none. + * + * Field by field rather than by spread: a caller building `{ initial: maybeInitial }` from an + * optional value passes an explicit undefined, which a spread would take as the answer. + */ +function pacing(delay: ReloadDelay) { + const initial = Milli(delay.initial ?? DEFAULT_DELAY.initial); + const max = Milli(delay.max ?? DEFAULT_DELAY.max); + const cap = max > 0 ? max : undefined; + const multiplier = delay.multiplier ?? DEFAULT_DELAY.multiplier; + if (!Number.isFinite(multiplier)) throw new RangeError(`invalid delay.multiplier: ${multiplier}`); + // Zero would count every session as healthy, resetting the retry window forever under a + // peer that drops each one on sight. + const healthy = Milli(delay.healthy ?? DEFAULT_DELAY.healthy); + if (healthy === 0) throw new RangeError("delay.healthy must be positive"); + const timeout = Milli(delay.timeout ?? DEFAULT_DELAY.timeout); + // A multiplier below 1 means no growth, not a delay that shrinks to nothing. + const growth = Math.max(multiplier, 1); + + return { + initial: cap === undefined ? initial : Milli(Math.min(initial, cap)), + healthy, + timeout, + // How long a session must last to start a new run of redirects. One that outlived the + // capped delay already redials no faster than the backoff would allow. Uncapped, the + // healthy bar is the only rate the config names. + settled: cap ?? healthy, + /** The delay after one that waited `delay`. */ + next(delay: Milli): Milli { + const next = Math.min(delay * growth, cap ?? Number.POSITIVE_INFINITY); + // Saturates, as Rust's Duration does, rather than overflowing the wait in nanoseconds. + return Number.isFinite(next * 1_000_000) ? Milli(next) : delay; + }, + }; +} + /** How often the send-rate estimate is sampled from the live transport. */ const BANDWIDTH_POLL = Nano.fromMilli(Milli(100)); @@ -275,6 +325,8 @@ export class Reload { this.url = Signal.from(props?.url); this.enabled = Signal.from(props?.enabled ?? true); this.delay = props?.delay ?? {}; + // Validated here, like the timeout, rather than by every retry. + pacing(this.delay); this.goaway = props?.goaway ?? {}; this.redirect = this.#redirect; this.versions = normalizeVersions(props); @@ -429,6 +481,9 @@ export class Reload { // straight away, with no backoff. for (;;) { const dialing = this.#redirect.peek() ?? url; + // The retry window counts from the first dial of a run, so a dial that hangs + // spends it too. + this.#deadline ??= this.#window(now()); this.#dialing = true; let connection: Established; @@ -485,7 +540,7 @@ export class Reload { if (!this.#migrate(connection, at, ended)) return; const after = this.#redirect.peek(); - // Two peers that each outlive the initial delay can still bounce us between + // Two peers that each hold a session past the healthy bar can still bounce us between // them forever. Returning to an endpoint that already sent us elsewhere in this // run of migrations escalates the backoff, which never resets mid-loop, so the // retry window still applies. A one-way rolling restart never revisits one, and @@ -493,8 +548,9 @@ export class Reload { // A session that outlived the capped delay already redials no faster than the // backoff would allow, so it starts a new run: rolling restarts days apart // never add up to a loop. + const { settled, healthy } = this.#pacing(); const lived = Instant.durationSince(now(), connected); - if (lived >= Nano.fromMilli(this.delay?.max ?? DEFAULT_DELAY.max)) this.#redirects.reset(); + if (lived >= Nano.fromMilli(settled)) this.#redirects.reset(); // Only a redirect this GOAWAY named is a move. An empty or ignored one reconnects // in place, even when that reruns the race a WebSocket fallback won. const from = endpoint(at); @@ -504,11 +560,13 @@ export class Reload { return; } - // A session that outlived the initial delay was healthy, so its handover is not a - // failure. One redirected almost at once still migrates, but through the backoff, - // so two peers bouncing us between them escalate to the capped delay. - if (lived < Nano.fromMilli(this.#initial())) { - this.#retry(effect, connected, new Error("peer redirected immediately")); + // A healthy session's handover is not a failure. One redirected sooner still + // migrates, but through the backoff, so two peers bouncing us between them + // escalate to the capped delay. An empty URI is a peer restarting, which drains + // each new session until it goes; every one serves, so that is no failure either. + if (lived < Nano.fromMilli(healthy)) { + if (ended.uri === "") this.#restart(effect); + else this.#retry(effect, connected, new Error("peer redirected immediately")); return; } this.#delay = undefined; @@ -599,8 +657,41 @@ export class Reload { if (draining) this.#end(draining); } - #initial(): Milli { - return this.delay?.initial ?? DEFAULT_DELAY.initial; + // Resolved per use rather than at construction, so an edit to `delay` (including one that + // drops a field back to its default) applies to the next retry. + #pacing() { + return pacing(this.delay ?? {}); + } + + // When a retry window starting `at` expires. + #window(at: Instant): number { + const { timeout } = this.#pacing(); + return timeout > 0 ? Instant.add(at, Nano.fromMilli(timeout)) : Number.POSITIVE_INFINITY; + } + + /** + * Wait out the backoff after a restarting peer drained a session short of the healthy bar. + * The delay escalates, so the redials cannot hammer it, but the wait never spends the retry + * window: the window restarts once the wait is over. + */ + #restart(effect: Effect): void { + if (this.established.peek() === undefined) this.status.set("disconnected"); + const wait = this.#backoff(); + const tick = this.#tick.peek() + 1; + effect.timer(() => { + this.#deadline = undefined; + this.#tick.update((prev) => Math.max(prev, tick)); + }, Nano(wait)); + } + + // The jittered wait before the next attempt, escalating the delay for the one after. + // Equal jitter, so a fleet of tabs knocked offline together doesn't reconnect on the same tick. + #backoff(): number { + const pacing = this.#pacing(); + this.#delay ??= pacing.initial; + const wait = Nano.fromMilli(this.#delay) * (0.5 + Math.random() / 2); + this.#delay = pacing.next(this.#delay); + return wait; } /** @@ -609,26 +700,17 @@ export class Reload { * `cause` the error that killed it, if it died with one. */ #retry(effect: Effect, connected: Instant | undefined, cause?: unknown): void { - // Resolved per sequence rather than at construction, so an edit to `delay` (including - // one that drops a field back to its default) applies to the next retry. Field by - // field rather than by spread: a caller building `{ initial: maybeInitial }` from an - // optional value passes an explicit undefined, which a spread would take as the - // answer, turning the backoff into NaN or the window into forever. - const delay = this.delay ?? {}; - const initial = this.#initial(); - const multiplier = delay.multiplier ?? DEFAULT_DELAY.multiplier; - const max = delay.max ?? DEFAULT_DELAY.max; - const timeout = delay.timeout ?? DEFAULT_DELAY.timeout; - // Report disconnected during the backoff rather than when the retry reruns the // effect, unless a drained predecessor still serves until it retires. if (this.established.peek() === undefined) this.status.set("disconnected"); - // A session that outlived the initial delay was healthy, so clear the backoff and - // start a fresh retry window: a one-off drop should reconnect promptly. Anything - // shorter is a peer that accepts and immediately severs, which has to keep - // escalating or we hammer it forever at the initial delay. - if (connected !== undefined && Instant.durationSince(now(), connected) >= Nano.fromMilli(initial)) { + // A healthy session's end clears the backoff and starts a fresh retry window: a one-off + // drop should reconnect promptly. Anything shorter is a peer that accepts and soon + // severs, which has to keep escalating or we hammer it forever at the initial delay. + if ( + connected !== undefined && + Instant.durationSince(now(), connected) >= Nano.fromMilli(this.#pacing().healthy) + ) { this.#delay = undefined; this.#deadline = undefined; } @@ -655,21 +737,25 @@ export class Reload { } const at = now(); - this.#delay ??= initial; - this.#deadline ??= timeout > 0 ? Instant.add(at, Nano.fromMilli(timeout)) : Number.POSITIVE_INFINITY; - - if (at >= this.#deadline) { - console.warn("reconnect timed out"); + // A healthy session's end starts the window here. + this.#deadline ??= this.#window(at); + const wait = this.#backoff(); + + // No attempt starts once the window has passed: a wait that reaches the deadline gives up + // there instead of dialing. + const left = this.#deadline - at; + if (wait >= left) { // A graceful close has no error, so report the timeout itself. - this.#giveUp(cause === undefined ? new Error("reconnect timed out") : error(cause)); + const failure = cause === undefined ? new Error("reconnect timed out") : error(cause); + const giveUp = () => { + console.warn("reconnect timed out"); + this.#giveUp(failure); + }; + if (left > 0) effect.timer(giveUp, Nano(left)); + else giveUp(); return; } - // Equal jitter, so a fleet of tabs knocked offline together doesn't reconnect on the same - // tick, and never past the deadline the retry window promised. - const wait = Math.min(Nano.fromMilli(this.#delay) * (0.5 + Math.random() / 2), this.#deadline - at); - this.#delay = Milli(Math.min(this.#delay * multiplier, max)); - const tick = this.#tick.peek() + 1; effect.timer(() => this.#tick.update((prev) => Math.max(prev, tick)), Nano(wait)); } diff --git a/quest/m1/README.md b/quest/m1/README.md index 9c55c18b5ae..0311e9396bf 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -138,7 +138,6 @@ Catalog HLS field. - [A/V clock](/quest/m1/av-clock.md) - the audio playhead drives Sync.reference while audio plays, through per-track sync handles - [Container reads drop backfill](/quest/m1/read-backfill.md) - the JS container consumer drops groups below its read cursor like Rust - [Buffered playback subscribes in ascending order](/quest/m1/buffered-ascending.md) - a buffered `` asks for the oldest group first, so a voice reply's opening arrives first, and audio's head hold shrinks to the floor -- [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 - [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 diff --git a/quest/m1/js-reload-config.md b/quest/m1/js-reload-config.md deleted file mode 100644 index dc1aba2edba..00000000000 --- a/quest/m1/js-reload-config.md +++ /dev/null @@ -1,22 +0,0 @@ -# [S] JS reload takes the Rust backoff config - -## Goal - -`@moq/net`'s reload loop takes the same backoff settings as Rust (`initial`, -`max`, and `healthy`, the time a session must stay up to count as healthy) -and accepts no option it ignores. - -## Plan - -Rust's moq-tokio split its healthy bar out of `backoff.initial` into -`backoff.healthy` ([moq-dev/moq#6529](https://github.com/moq-dev/moq/pull/6529)). `ReloadDelay` -(`js/net/src/connection/reload.ts`) still uses `initial` as the healthy bar. -Add `healthy` with Rust's default and a mocked-time test. - -`ReloadProps` is `Omit`, so it accepts `extensions`, but -the reload loop never passes them to `connect()`. Decided 2026-10-23 -(maintainer): one quest for both. Omit `extensions` from `ReloadProps`, since -[moq-net exports](/quest/m1/api-audit/net-exports.md) makes it `@internal`, -unless that quest lands keeping it public, in which case forward it. - -Public API: breaking JS option change; the Impact bullet says how to migrate. Wire: none.