From b4b968cc24db07abb9704376e41b40b0bb3499a9 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 12 Oct 2026 20:36:41 -0700 Subject: [PATCH 1/4] quest(m1): plan pool-test fake timers, duration parser defaults, and cancelled demand Co-Authored-By: Claude Opus 5.5 --- quest/m1/README.md | 7 ++++ quest/m1/cli-duration-defaults.md | 52 ++++++++++++++++++++++++++++++ quest/m1/js-demand-cancel.md | 53 +++++++++++++++++++++++++++++++ quest/m1/js-pool-test-time.md | 41 ++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 quest/m1/cli-duration-defaults.md create mode 100644 quest/m1/js-demand-cancel.md create mode 100644 quest/m1/js-pool-test-time.md diff --git a/quest/m1/README.md b/quest/m1/README.md index e450787a17d..9fba717eb3c 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -51,6 +51,10 @@ Imported 2026-10-12 from GitHub issues: the 0.17 warm FETCH stall and the moq-lite malformed-input closes rank just below Dropped sources, and #5347 folded into Dropped sources. +Added 2026-10-12 as PR follow-ups: fake timers for the JS pool +tests (#5355), duration parser defaults (#5350), and cancelled origin +demand (#5214), each ranked beside the work it shares code with. + ## Required - [Interop close logs](/quest/m1/interop-close-log.md) - logging fix landed; delete once the required Interop run is green @@ -80,6 +84,7 @@ folded into Dropped sources. - [Live TS clock validation](/quest/m1/ts-live-clock.md) - resolve the local PCR-rate failure with reproducible timing evidence and CI controls - [Same-instance TS resume](/quest/m1/ts-same-instance-resume.md) - prove valid continuation and fix the unexpected final exporter failure without weakening identity - [More tests under load](/quest/m1/test-flakes-2/README.md) - the second round of load-only failures, one quest per flake, fixed at the cause +- [pool.test.ts on fake timers](/quest/m1/js-pool-test-time.md) - js/net's connection pool tests advance Bun's fake timers instead of sleeping or patching `performance.now` - [Drill mutation gate](/quest/m1/drill-mutation-gate.md) - a PR touching a drill mutation's target runs that mutation's sensitivity check, advisory until the drills run on controlled time - [Plan: a public model](/quest/m1/model-public-surface.md) - every crate-private model item is made public or unnecessary, so a custom publisher or subscriber builds from the public model alone - [Pipelined requests](/quest/m1/pipeline-requests/README.md) - SUBSCRIBE and the first FETCH go out with the track-info request at every hop, so first data arrives a round trip sooner per hop @@ -157,9 +162,11 @@ folded into Dropped sources. - [Front deadlines](/quest/m1/front-deadline-index.md) - a front's per-event cost stops growing with its track count: an expiry index and per-track wakes, proven by a churn benchmark - [io_uring handshake deadline](/quest/m1/listener-deadlines.md) - the io_uring workers apply `listen.timeout` to the handshake - [Rust papercuts](/quest/m1/papercuts-rs.md) - HTTP refusals are counted, and a `u64::MAX` resume is unbounded +- [Duration parser defaults](/quest/m1/cli-duration-defaults.md) - a moq-tokio duration set in code beats the parser default on a parsed or merged config, zero included, after #5350 - [Front parking](/quest/m1/origin-front-parks.md) - an unroutable request waits on a front instead of re-asking on every route-table move - [Route wakes](/quest/m1/route-wakes.md) - a route change wakes only the fronts it can move, so pool churn stops scaling with served paths - [Publish channel count](/quest/m1/publish-audio-channel-count.md) - forcing a channel count on an Audio.Capture stops costing the subscriber gaps of silence +- [Cancelled demand](/quest/m1/js-demand-cancel.md) - a JS requester that leaves before a dynamic handler answers withdraws its origin demand, so a stalled handler holds nothing for it - [JS request deadline](/quest/m1/js-request-deadline.md) - each JS request, PUBLISH_NAMESPACE included, has one fatal 10 s timer from create to answer and fails fast without stream credit, so nothing queues or retries - [Rust request credit](/quest/m1/rs-request-credit.md) - a moq-net request fails at once without stream credit instead of waiting - [qmux no-wait opens](/quest/m1/qmux-no-wait.md) - @moq/qmux rejects an over-limit create when waitUntilAvailable is false, like Chrome diff --git a/quest/m1/cli-duration-defaults.md b/quest/m1/cli-duration-defaults.md new file mode 100644 index 00000000000..96f3da898f3 --- /dev/null +++ b/quest/m1/cli-duration-defaults.md @@ -0,0 +1,52 @@ +# [M] A duration set in code beats the parser default + +## Goal + +On a moq-tokio config built by the command line or merged from settings, a +duration a caller sets in code takes effect, zero included, unless its flag or +env var was actually given. #5350 fixes this for `connect.backoff.timeout`. +The rest still ignore the code: connect `race`, `resolution_delay`, and +`timeout`; `listen.timeout`; QUIC `idle_timeout` and `keep_alive`; backoff +`initial` and `max`; GOAWAY `handover`; and WebSocket `delay`. + +## Plan + +The cause, from #5350: usage builds `default_value_t` by formatting and +reparsing it, so `CliDuration::fallback` reaches the struct as an explicit +value and `CliDuration::resolve` prefers it over the typed field. And a parse +leaves each `#[usage(skip)]` typed field at `Duration::ZERO`, which `resolve` +reads as unset, so a zero set afterwards looks like no value. Zero is a real +setting for most of these fields: wait forever, disable keep-alive, dial every +address at once, or give WebSocket no head start. + +These aren't one-line fixes. Each field's public type changes, and its callers +in moq-c, moq-ffi, moq-gst, moq-relay, and the moq-tokio tests (about 70 +sites) follow. + +Recommended: give every field #5350's shape. The typed field becomes +`Option` (`None` is unset, and `Default` holds the default), the +`*_arg` field loses its parser default, and each field resolves the flag, then +the typed field, then the default. `fallback`, `resolve`, and the `explicit` +bit then have no callers, so delete them and leave `CliDuration` as the +humantime parser. + +Rejected: fixing usage (jdx/usage, an outside party) to assign +`default_value_t` without the string round-trip. It fixes only the first +half; skipped fields still start at zero, so the zero ambiguity stays. + +Start after #5350 merges, since this reuses its `serde_duration::option` and +shape. Like #5350, help no longer prints these flags' defaults, because +usage's `default` sets a parser value; each doc comment states its default. +Use a help-only default instead if usage offers one. + +Extend #5350's `a_timeout_set_in_code_beats_the_parser_default` to every field: +a parsed config, a merged round-trip with zero and nonzero values, a given +flag still winning, and a config built in code. It must fail on main. + +Public API: breaking, each listed `moq_tokio` field goes from `Duration` to +`Option`. The C ABI and FFI records keep their `has_*` flags and +don't change. Wire: none. + +## Related + +- [#5350](https://github.com/moq-dev/moq/pull/5350) - the backoff timeout fix this generalizes diff --git a/quest/m1/js-demand-cancel.md b/quest/m1/js-demand-cancel.md new file mode 100644 index 00000000000..16798dd6dbc --- /dev/null +++ b/quest/m1/js-demand-cancel.md @@ -0,0 +1,53 @@ +# [S] A cancelled request releases its origin demand + +## Goal + +In `@moq/net`, a requester that leaves before a dynamic handler answers its +broadcast stops holding the origin's demand for it. Once the last requester +for a path leaves, that path's pending request is withdrawn, and its waiter +count and any stored rejection go with it. Other requesters for the same path +keep waiting. This covers lite SUBSCRIBE, FETCH, and TRACK info, and IETF +SUBSCRIBE. + +## Plan + +Found in #5214's review and deferred while #5314 rewrote the request path; +#5314 has merged. + +The bug: `Consumer.#demand` in `js/net/src/origin.ts` enqueues the path on +its `ServeState`, bumps `demanding`, and waits on `settled` until the handler +answers, the route closes, or a reset releases it. Nothing ends that wait when +the requester leaves. The lite and IETF SUBSCRIBE paths race it with +`untilAborted`, which stops the caller waiting but leaves the promise running, +and lite FETCH and TRACK don't race it at all. So the `pending` request, its +queue entry, and the `demanding` count live until the handler answers, which +may be never. With a stalled handler, a peer that subscribes to distinct paths +and cancels each one grows that state without bound, while #5214's caps hand +the slots back. + +Recommended: `demand` takes an `AbortSignal` on the internal wire interface +(`js/net/src/wire.ts`). On abort the waiter drops its count, and the last one +out withdraws the request the way `ServeState.reset` does, but for one path: +out of `pending` and the queue, finished so a late answer closes its front. +Callers pass the signal they already hold (`left.signal`, `hold`, or one tied +to the FETCH stream) instead of wrapping the call in `untilAborted`. Check +Rust's behavior (`Requests::remove_if` and `ServeState::forget` in +`rs/moq-net/src/model/origin.rs`) and match it, including whether a request a +handler has already taken is withdrawn. + +Don't tell a handler that its taken request was withdrawn. That needs public +API on `Request`, and the bound doesn't depend on it; propose it separately if +Rust has the equivalent. + +Regression: a dynamic handler that never answers; in both protocol families, +subscribe to many distinct paths and cancel each before an answer, then check +that the origin holds nothing for them. Also check that a second requester on +a shared path still resolves after the first cancels. Drive it on events, and +use fake timers for any wait. It must fail on main. + +Public API: none, since `demand` is internal. Wire: none. + +## Related + +- [JS request deadline](/quest/m1/js-request-deadline.md) - once a request times out after 10 s, every unanswered one is cancelled, so each would hold demand without this +- [#5214](https://github.com/moq-dev/moq/pull/5214) - the JS session caps whose cancelled slots this finishes releasing diff --git a/quest/m1/js-pool-test-time.md b/quest/m1/js-pool-test-time.md new file mode 100644 index 00000000000..b577ee75530 --- /dev/null +++ b/quest/m1/js-pool-test-time.md @@ -0,0 +1,41 @@ +# [S] pool.test.ts on fake timers + +## Goal + +`js/net/src/connection/pool.test.ts` neither reads the wall clock nor waits on +a real timer. The linger, retry-window, and outage tests advance Bun's fake +timers instead of sleeping or patching `performance.now`, and each still fails +against the bug it was written for. + +## Plan + +Raised in #5355's review: its own regression moved to fake timers, the rest of +the file did not. Still on real time as of `079d7d8d4`: + +- `expired()` waits `linger * 15` real milliseconds, and the longest-linger + test waits 50 ms. +- `waitUntil` polls `Date.now` through real `setTimeout(0)` settles, for up to + 1 s, and 15 s in the shared-outage test. +- The shared-outage and private-partial-delay tests speed up the retry window + by monkeypatching `performance.now`, and the shared one sleeps 2 s under a + 30 s test timeout. + +Use Bun's `jest.useFakeTimers()`, which also drives `performance.now` (#5355), +as `connect.test.ts`, `js/publish/src/source/retry.test.ts`, and #5355's test +already do. Check that it drives `Date.now` too, or drop the `Date` reads. +Replace `settle`, `waitUntil`, and `expired` with one helper that advances the +clock and drains microtasks; the mock transport's handshake must still finish +inside a drain. + +This doesn't wait for `@moq/time`: [JS on @moq/time](/quest/m1/time/js-migrate.md) +already moves every `jest.useFakeTimers` site onto its `Manual` clock, so the +swap there is mechanical, and these tests stop costing seconds and load +sensitivity now. A test that still seems to need a real wait has a cause to +fix, not a wait to widen. + +Public API: none. Wire: none. + +## Related + +- [JS on @moq/time](/quest/m1/time/js-migrate.md) - later moves these fake timers onto the `Manual` clock +- [More tests under load](/quest/m1/test-flakes-2/README.md) - the same rule for tests that have already flaked From 4ab19f5bb85f9135b8bff5fcf280bccc4b635205 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 12 Oct 2026 20:40:24 -0700 Subject: [PATCH 2/4] quest(m1): record the 2026-10-13 decisions Co-Authored-By: Claude Opus 5.5 --- quest/m1/cli-duration-defaults.md | 4 ++-- quest/m1/js-demand-cancel.md | 8 ++++---- quest/m1/js-pool-test-time.md | 6 +++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/quest/m1/cli-duration-defaults.md b/quest/m1/cli-duration-defaults.md index 96f3da898f3..d5d17810364 100644 --- a/quest/m1/cli-duration-defaults.md +++ b/quest/m1/cli-duration-defaults.md @@ -23,11 +23,11 @@ These aren't one-line fixes. Each field's public type changes, and its callers in moq-c, moq-ffi, moq-gst, moq-relay, and the moq-tokio tests (about 70 sites) follow. -Recommended: give every field #5350's shape. The typed field becomes +Decided 2026-10-13: give all ten fields #5350's shape. The typed field becomes `Option` (`None` is unset, and `Default` holds the default), the `*_arg` field loses its parser default, and each field resolves the flag, then the typed field, then the default. `fallback`, `resolve`, and the `explicit` -bit then have no callers, so delete them and leave `CliDuration` as the +bit then have no callers, so delete them (also decided) and leave `CliDuration` as the humantime parser. Rejected: fixing usage (jdx/usage, an outside party) to assign diff --git a/quest/m1/js-demand-cancel.md b/quest/m1/js-demand-cancel.md index 16798dd6dbc..d3a8af64ed3 100644 --- a/quest/m1/js-demand-cancel.md +++ b/quest/m1/js-demand-cancel.md @@ -25,7 +25,7 @@ may be never. With a stalled handler, a peer that subscribes to distinct paths and cancels each one grows that state without bound, while #5214's caps hand the slots back. -Recommended: `demand` takes an `AbortSignal` on the internal wire interface +`demand` takes an `AbortSignal` on the internal wire interface (`js/net/src/wire.ts`). On abort the waiter drops its count, and the last one out withdraws the request the way `ServeState.reset` does, but for one path: out of `pending` and the queue, finished so a late answer closes its front. @@ -35,9 +35,9 @@ Rust's behavior (`Requests::remove_if` and `ServeState::forget` in `rs/moq-net/src/model/origin.rs`) and match it, including whether a request a handler has already taken is withdrawn. -Don't tell a handler that its taken request was withdrawn. That needs public -API on `Request`, and the bound doesn't depend on it; propose it separately if -Rust has the equivalent. +Decided 2026-10-13: don't signal the handler that a request it took was +withdrawn. Its late answer just closes its front, and `Request` gets no new +public API; the bound doesn't depend on it. Regression: a dynamic handler that never answers; in both protocol families, subscribe to many distinct paths and cancel each before an answer, then check diff --git a/quest/m1/js-pool-test-time.md b/quest/m1/js-pool-test-time.md index b577ee75530..2922dec653d 100644 --- a/quest/m1/js-pool-test-time.md +++ b/quest/m1/js-pool-test-time.md @@ -20,9 +20,13 @@ the file did not. Still on real time as of `079d7d8d4`: by monkeypatching `performance.now`, and the shared one sleeps 2 s under a 30 s test timeout. +Decided 2026-10-13: switch to Bun's fake timers now, as a standalone quest, +rather than waiting for `@moq/time`. + Use Bun's `jest.useFakeTimers()`, which also drives `performance.now` (#5355), as `connect.test.ts`, `js/publish/src/source/retry.test.ts`, and #5355's test -already do. Check that it drives `Date.now` too, or drop the `Date` reads. +already do. Check that it drives `Date.now` too, or drop the `Date` reads +(left to the implementer, decided 2026-10-13). Replace `settle`, `waitUntil`, and `expired` with one helper that advances the clock and drains microtasks; the mock transport's handshake must still finish inside a drain. From 3d30bbc0bb223bb4e68bb27f06f39d0ff94ada2f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 12 Oct 2026 20:44:23 -0700 Subject: [PATCH 3/4] quest(m1): keep a cancelled path's request while a local requester needs it Co-Authored-By: Claude Opus 5.5 --- quest/m1/js-demand-cancel.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/quest/m1/js-demand-cancel.md b/quest/m1/js-demand-cancel.md index d3a8af64ed3..4662e245f35 100644 --- a/quest/m1/js-demand-cancel.md +++ b/quest/m1/js-demand-cancel.md @@ -26,9 +26,13 @@ and cancels each one grows that state without bound, while #5214's caps hand the slots back. `demand` takes an `AbortSignal` on the internal wire interface -(`js/net/src/wire.ts`). On abort the waiter drops its count, and the last one -out withdraws the request the way `ServeState.reset` does, but for one path: -out of `pending` and the queue, finished so a late answer closes its front. +(`js/net/src/wire.ts`). On abort the waiter drops its count. The request is +withdrawn the way `ServeState.reset` does, but for one path (out of `pending` +and the queue, finished so a late answer closes its front), only when nobody +else needs it. `demanding` counts wire waiters alone: a local +`Consumer.request()` reaches the same pending request through +`OriginState.route()`, which enqueues without counting, so the withdrawal +must also see that no local request or failover still routes to the path. Callers pass the signal they already hold (`left.signal`, `hold`, or one tied to the FETCH stream) instead of wrapping the call in `untilAborted`. Check Rust's behavior (`Requests::remove_if` and `ServeState::forget` in @@ -42,7 +46,9 @@ public API; the bound doesn't depend on it. Regression: a dynamic handler that never answers; in both protocol families, subscribe to many distinct paths and cancel each before an answer, then check that the origin holds nothing for them. Also check that a second requester on -a shared path still resolves after the first cancels. Drive it on events, and +a shared path still resolves after the first cancels, both a second peer and a +local `Consumer.request()`, with the handler answering after the peer +cancels. Drive it on events, and use fake timers for any wait. It must fail on main. Public API: none, since `demand` is internal. Wire: none. From d1b51f573ea2b6ffa96f41c0b8128211a29ad626 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 12 Oct 2026 20:50:26 -0700 Subject: [PATCH 4/4] quest(m1): cover FETCH and TRACK in the cancelled-demand regression Co-Authored-By: Claude Opus 5.5 --- quest/m1/js-demand-cancel.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/quest/m1/js-demand-cancel.md b/quest/m1/js-demand-cancel.md index 4662e245f35..56fbac87da5 100644 --- a/quest/m1/js-demand-cancel.md +++ b/quest/m1/js-demand-cancel.md @@ -43,13 +43,14 @@ Decided 2026-10-13: don't signal the handler that a request it took was withdrawn. Its late answer just closes its front, and `Request` gets no new public API; the bound doesn't depend on it. -Regression: a dynamic handler that never answers; in both protocol families, -subscribe to many distinct paths and cancel each before an answer, then check -that the origin holds nothing for them. Also check that a second requester on -a shared path still resolves after the first cancels, both a second peer and a -local `Consumer.request()`, with the handler answering after the peer -cancels. Drive it on events, and -use fake timers for any wait. It must fail on main. +Regression: a dynamic handler that never answers; for each covered request +(SUBSCRIBE in both protocol families, lite FETCH, and lite TRACK), request +many distinct paths and cancel each before an answer, then check that the +origin holds nothing for them. Also check that a second requester on a shared +path still resolves after the first cancels, both a second peer and a local +`Consumer.request()`, with the handler answering after the peer cancels. +Drive it on events, and use fake timers for any wait. Each case must fail on +main. Public API: none, since `demand` is internal. Wire: none.