From a73c65df3bc3eec506e7237ca51939b704f511ff Mon Sep 17 00:00:00 2001 From: OneTooMany Date: Wed, 7 Oct 2026 11:26:16 +0200 Subject: [PATCH 1/5] quest: plan JS requests waiting for a stream slot without timing out Co-Authored-By: Claude Opus 5.5 --- quest/m1/README.md | 1 + quest/m1/js-stream-slot-wait.md | 88 +++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 quest/m1/js-stream-slot-wait.md diff --git a/quest/m1/README.md b/quest/m1/README.md index 5b3caebb26e..ddf8eabe634 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -130,6 +130,7 @@ blocks. The quests that gated m0 lines moved under them. - [JS track handover](/quest/m1/js-group-handover.md) - a JS track subscription resumes across a route swap from the first frame it lacks, so `test/drain` passes at zero latency budget - [JS startup hole](/quest/m1/js-startup-hole.md) - a `@moq/hang` consumer delivers its first live group at once, even when an empty group died before it - [JS GOAWAY requests](/quest/m1/js-goaway-requests.md) - after GOAWAY the JS client opens no new request on the old session, like Rust +- [JS stream slot wait](/quest/m1/js-stream-slot-wait.md) - a JS request waiting for a stream slot never times out as ControlTimeout and leaves at most one waiting open, so @moq/watch's re-subscribe can't pile them up - [Drain handshakes](/quest/m1/drain-handshakes.md) - a drain GOAWAYs and waits for sessions still in their handshake instead of exiting under them - [Transport upgrade](/quest/m1/transport-upgrade/README.md) - a session that came up over WebSocket moves to QUIC once the QUIC dial lands, handing over without dropping a group - [Scope track priority](/quest/m1/track-priority-scope.md) - priority orders one owner's streams, and a shared cluster session is fair across tenants diff --git a/quest/m1/js-stream-slot-wait.md b/quest/m1/js-stream-slot-wait.md new file mode 100644 index 00000000000..5468d7d6d2f --- /dev/null +++ b/quest/m1/js-stream-slot-wait.md @@ -0,0 +1,88 @@ +# [M] JS requests wait for a stream slot without timing out + +## Goal + +A `@moq/net` request whose stream open is waiting for the peer to free a +stream slot never fails with `ControlTimeout`, and never leaves more than one +waiting open per live request. The 10 s setup deadline covers only the peer's +answer once the stream is open, so `ControlTimeout` means "the peer never +answered", and `@moq/watch`'s re-subscribe on it +([#4999](https://github.com/moq-dev/moq/pull/4999)) can't pile up waiting +opens on Firefox or the WebSocket fallback. Covers every per-request setup on +lite and IETF: subscribe, track info, fetch, and announce interest. + +Out of scope: publisher group streams, and Chrome's immediate rejection +(below). + +## Plan + +Opens use `waitUntilAvailable: true`, and the subscribe setup deadline is +started before the open, so a request waiting on stream credit times out as a +`ControlTimeout`. Neither WebTransport nor `@moq/qmux` can cancel a waiting +create; `@moq/net` resets the stream when it finally opens. Each retry after +such a timeout therefore adds another waiting create, served oldest first. + +Engine behaviour (2026-10-07): + +- Firefox ignores `waitUntilAvailable` and always queues an over-limit create + (FIFO, no cancel). +- `@moq/qmux` (the WebSocket fallback, and so Safari) waits on its stream + credit FIFO, ignoring the flag, with no cancel. +- Chrome never waits: an over-limit create rejects at once with a + `NetworkError`, whatever the flag, until crbug.com/487117768 lands. Once it + does, Chrome waits like Firefox, and the spec offers no cancel either. + +Decided (2026-10-07, with OneTooMany): + +- A request waits for a slot with no deadline. It gives up only when its + demand leaves or the session closes; a stream that opens after that is + reset. The response deadline starts once the stream is open. Rust already + works this way (no setup deadline, a dropped open is cancelled cleanly), and + the IETF publisher's announce advertisement already opens outside its + timeout. Rejected: keeping an open deadline with a distinct "no stream + slot" error (still one waiting create per attempt, and callers must decide + whether to retry it), and a per-session opener that caps waiting creates, + hands a late stream to the next waiter and orders by priority (bounds + everything, but [L] and beyond this goal). +- `ControlTimeout` narrows to "opened, unanswered", which is what the lite + draft's 0x31 text already says. No draft change. +- Scope is every per-request setup, not only subscribe. +- Chrome's immediate rejection stays terminal. Fix the stale "Chrome silently + blocks" and "Chrome ~100" comments in both subscribers; the stream cap is + the peer's MAX_STREAMS (the Rust relay grants 10,000 by default). +- No cancel in `@moq/qmux`: with at most one waiting create per live request + it adds little. +- Documentation stays inline: comments and any doc describing the setup + timeout. + +Things to look out for: + +- The lite subscriber has no abandonment watch during setup (the IETF one has + `waitAbandoned`), so a request whose demand leaves while its open waits + needs one here. +- `Stream.open` needs a mode that waits until cancelled rather than until a + deadline; `Writer.tryOpen` already has a cancel. +- On lite-05+ a subscribe opens the TRACK stream and then the SUBSCRIBE + stream; both opens wait, and only the answer is under the deadline. +- On IETF drafts 14-16 requests ride the control stream and need no stream + credit; only real opens (draft 17, v16 SubscribeNamespace) are affected. +- Demand churn can still add waiting creates (a viewer leaves, the late + stream is reset, a new viewer opens again). That is bounded by viewers, not + time. + +Tests (mocked time): give the mock transport an optional stream limit with +FIFO creates and slots returned when a stream closes. With the limit held, a +subscribe whose open waits doesn't fail after 10 s; a watch-like retry loop +over several deadlines leaves at most one waiting create; a freed slot lets +the waiting create carry the SUBSCRIBE and the track delivers; a stream that +opened but got no answer still fails with `ControlTimeout`; demand leaving +during the wait resets the late stream. Cover lite and IETF draft 17. + +Public API: none. Behaviour: `ControlTimeout` no longer covers waiting for a +stream slot. Wire: none. + +## Related + +- [JS abandonment](/quest/m1/js-subscribe-abandonment.md) - edits the IETF setup path; land after its PRs to avoid conflicts +- [JS GOAWAY requests](/quest/m1/js-goaway-requests.md) - adds a check at every open site this touches; land after its PR +- [JS request window](/quest/m1/js-request-window.md) - the IETF setup can also wait, unbounded, on MAX_REQUEST_ID before its deadline starts From b9015e0d4e445f3ce9217f7c2d54f1f5cd07f555 Mon Sep 17 00:00:00 2001 From: OneTooMany Date: Wed, 7 Oct 2026 11:37:16 +0200 Subject: [PATCH 2/5] quest: bound js-stream-slot-wait's churn by demand cycles, rank it after JS abandonment Co-Authored-By: Claude Opus 5.5 --- quest/m1/README.md | 2 +- quest/m1/js-stream-slot-wait.md | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/quest/m1/README.md b/quest/m1/README.md index ddf8eabe634..b44af541b89 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -130,7 +130,6 @@ blocks. The quests that gated m0 lines moved under them. - [JS track handover](/quest/m1/js-group-handover.md) - a JS track subscription resumes across a route swap from the first frame it lacks, so `test/drain` passes at zero latency budget - [JS startup hole](/quest/m1/js-startup-hole.md) - a `@moq/hang` consumer delivers its first live group at once, even when an empty group died before it - [JS GOAWAY requests](/quest/m1/js-goaway-requests.md) - after GOAWAY the JS client opens no new request on the old session, like Rust -- [JS stream slot wait](/quest/m1/js-stream-slot-wait.md) - a JS request waiting for a stream slot never times out as ControlTimeout and leaves at most one waiting open, so @moq/watch's re-subscribe can't pile them up - [Drain handshakes](/quest/m1/drain-handshakes.md) - a drain GOAWAYs and waits for sessions still in their handshake instead of exiting under them - [Transport upgrade](/quest/m1/transport-upgrade/README.md) - a session that came up over WebSocket moves to QUIC once the QUIC dial lands, handing over without dropping a group - [Scope track priority](/quest/m1/track-priority-scope.md) - priority orders one owner's streams, and a shared cluster session is fair across tenants @@ -161,6 +160,7 @@ blocks. The quests that gated m0 lines moved under them. - [Copy-walk bench](/quest/m1/admission-bench.md) - a front's walk over its copies on a route change is benchmarked over tracks and copies - [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 - [JS abandonment](/quest/m1/js-subscribe-abandonment.md) - a viewer returning during IETF subscribe setup keeps its track across microtasks +- [JS stream slot wait](/quest/m1/js-stream-slot-wait.md) - a JS request waiting for a stream slot never times out as ControlTimeout and leaves at most one waiting open, so @moq/watch's re-subscribe can't pile them up - [E2EE](/quest/m1/e2ee/README.md) - TypeScript and Rust peers interoperate over encrypted broadcasts no relay can decrypt - [#3056](/quest/m1/3056-watch-video-decoder-captures-the-rewind-generation-at.md) - watch: the video decoder resets on a declared discontinuity - [#933](/quest/m1/933-video-rotation-metadata-not-propagated-from-mobile-camera.md) - the catalog rotation follows the live camera's orientation diff --git a/quest/m1/js-stream-slot-wait.md b/quest/m1/js-stream-slot-wait.md index 5468d7d6d2f..e59d24694e0 100644 --- a/quest/m1/js-stream-slot-wait.md +++ b/quest/m1/js-stream-slot-wait.md @@ -66,9 +66,11 @@ Things to look out for: stream; both opens wait, and only the answer is under the deadline. - On IETF drafts 14-16 requests ride the control stream and need no stream credit; only real opens (draft 17, v16 SubscribeNamespace) are affected. -- Demand churn can still add waiting creates (a viewer leaves, the late - stream is reset, a new viewer opens again). That is bounded by viewers, not - time. +- Demand churn can still add waiting creates: each time demand leaves while + an open waits and then returns, the old create stays queued and a new one + is made. That is bounded by how often demand comes and goes while slots are + held, not by time or by viewers. Bounding it too is the per-session + opener's job, rejected above as beyond this goal. Tests (mocked time): give the mock transport an optional stream limit with FIFO creates and slots returned when a stream closes. With the limit held, a @@ -76,7 +78,9 @@ subscribe whose open waits doesn't fail after 10 s; a watch-like retry loop over several deadlines leaves at most one waiting create; a freed slot lets the waiting create carry the SUBSCRIBE and the track delivers; a stream that opened but got no answer still fails with `ControlTimeout`; demand leaving -during the wait resets the late stream. Cover lite and IETF draft 17. +during the wait resets the late stream; repeated leave and return cycles +while slots stay held leave one queued create per cycle, no more. Cover +lite and IETF draft 17. Public API: none. Behaviour: `ControlTimeout` no longer covers waiting for a stream slot. Wire: none. From 2d8b619694448eb1a3c76ffbc4fba92ff7eab564 Mon Sep 17 00:00:00 2001 From: OneTooMany Date: Wed, 7 Oct 2026 12:14:09 +0200 Subject: [PATCH 3/5] quest: name the open deadline, the stall warning and each request path in js-stream-slot-wait Co-Authored-By: Claude Opus 5.5 --- quest/m1/js-stream-slot-wait.md | 58 ++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/quest/m1/js-stream-slot-wait.md b/quest/m1/js-stream-slot-wait.md index e59d24694e0..b09c6102192 100644 --- a/quest/m1/js-stream-slot-wait.md +++ b/quest/m1/js-stream-slot-wait.md @@ -16,10 +16,13 @@ Out of scope: publisher group streams, and Chrome's immediate rejection ## Plan -Opens use `waitUntilAvailable: true`, and the subscribe setup deadline is -started before the open, so a request waiting on stream credit times out as a -`ControlTimeout`. Neither WebTransport nor `@moq/qmux` can cancel a waiting -create; `@moq/net` resets the stream when it finally opens. Each retry after +Opens use `waitUntilAvailable: true`, and two deadlines run before a request +has a stream: each open's own `OPEN_TIMEOUT_MS` (`openWithin` in +`js/net/src/stream.ts`), and the subscribe setup deadline around the open. +Either rejects with a `TimeoutError`, which both subscribers map to +`ControlTimeout`, so a request waiting on stream credit times out as one. +Neither WebTransport nor `@moq/qmux` can cancel a waiting create; `@moq/net` +resets the stream when it finally opens. Each retry after such a timeout therefore adds another waiting create, served oldest first. Engine behaviour (2026-10-07): @@ -39,17 +42,39 @@ Decided (2026-10-07, with OneTooMany): reset. The response deadline starts once the stream is open. Rust already works this way (no setup deadline, a dropped open is cancelled cleanly), and the IETF publisher's announce advertisement already opens outside its - timeout. Rejected: keeping an open deadline with a distinct "no stream - slot" error (still one waiting create per attempt, and callers must decide - whether to retry it), and a per-session opener that caps waiting creates, + timeout. Both deadlines move off the wait: the per-request opens drop + `OPEN_TIMEOUT_MS` (moving only the setup deadline would leave the open's + own timeout producing `ControlTimeout` at 10 s), while the probe, SETUP and + publisher group streams keep it. Rejected: keeping an open deadline with a + distinct "no stream slot" error (still one waiting create per attempt, and + callers must decide whether to retry it), and a per-session opener that caps waiting creates, hands a late stream to the next waiter and orders by priority (bounds everything, but [L] and beyond this goal). +- A request that has waited for a slot past about 10 s logs a `console.warn` + once and keeps waiting, so a peer that never grants credit (a limit of zero, + or slots held forever) shows up for whoever debugs it instead of stalling + silently. It recovers as soon as a slot frees. Rejected: a long cap with a + distinct error that `@moq/watch` doesn't retry (the track dies, as on Chrome + today), and a silent stall that is only documented. - `ControlTimeout` narrows to "opened, unanswered", which is what the lite draft's 0x31 text already says. No draft change. -- Scope is every per-request setup, not only subscribe. -- Chrome's immediate rejection stays terminal. Fix the stale "Chrome silently - blocks" and "Chrome ~100" comments in both subscribers; the stream cap is - the peer's MAX_STREAMS (the Rust relay grants 10,000 by default). +- Scope is every per-request setup, not only subscribe. Each path gains a + cancellable wait for its slot and no new answer deadline: + - subscribe (lite TRACK and SUBSCRIBE opens, IETF draft 17): its existing + answer deadline starts once the stream is open; the wait ends when demand + leaves or the session closes; + - track info and fetch (lite `#exchange`): no answer deadline today and none + added; the wait ends with whatever ends the request today (the fetched + group closing, the subscriber closing); + - announce interest (lite) and SubscribeNamespace (IETF v16): long-lived, + so no answer deadline ever; the wait ends when the interest is dropped. +- Chrome's immediate rejection stays terminal. Fix the text it makes stale: + the "Chrome silently blocks" and "Chrome ~100" comments in both subscribers + (the stream cap is the peer's MAX_STREAMS; the Rust relay grants 10,000 by + default), `stream.ts`'s claim that a non-waiting open rejects with + `QuotaExceededError` and its "matches the subscribe budget" note, and the + "(browser stream limit reached?)" hint in both subscribe timeout messages, + which no longer names a plausible cause. - No cancel in `@moq/qmux`: with at most one waiting create per live request it adds little. - Documentation stays inline: comments and any doc describing the setup @@ -74,16 +99,19 @@ Things to look out for: Tests (mocked time): give the mock transport an optional stream limit with FIFO creates and slots returned when a stream closes. With the limit held, a -subscribe whose open waits doesn't fail after 10 s; a watch-like retry loop +subscribe whose open waits doesn't fail after 10 s, including an open +waiting past `OPEN_TIMEOUT_MS` with no response deadline involved, and logs +one warning; a watch-like retry loop over several deadlines leaves at most one waiting create; a freed slot lets the waiting create carry the SUBSCRIBE and the track delivers; a stream that opened but got no answer still fails with `ControlTimeout`; demand leaving during the wait resets the late stream; repeated leave and return cycles while slots stay held leave one queued create per cycle, no more. Cover -lite and IETF draft 17. +lite and IETF draft 17, and a fetch and an announce interest whose opens wait. -Public API: none. Behaviour: `ControlTimeout` no longer covers waiting for a -stream slot. Wire: none. +Public API: none; the open deadline and the new wait mode are internal to +`@moq/net`. Behaviour: `ControlTimeout` no longer covers waiting for a stream +slot, and a per-request open no longer fails after 10 s. Wire: none. ## Related From 3eba014749ea3981c320fab5521ccb79e24050b3 Mon Sep 17 00:00:00 2001 From: OneTooMany Date: Wed, 7 Oct 2026 12:14:23 +0200 Subject: [PATCH 4/5] quest: reflow js-stream-slot-wait Co-Authored-By: Claude Opus 5.5 --- quest/m1/js-stream-slot-wait.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quest/m1/js-stream-slot-wait.md b/quest/m1/js-stream-slot-wait.md index b09c6102192..64863ecd7ef 100644 --- a/quest/m1/js-stream-slot-wait.md +++ b/quest/m1/js-stream-slot-wait.md @@ -47,9 +47,9 @@ Decided (2026-10-07, with OneTooMany): own timeout producing `ControlTimeout` at 10 s), while the probe, SETUP and publisher group streams keep it. Rejected: keeping an open deadline with a distinct "no stream slot" error (still one waiting create per attempt, and - callers must decide whether to retry it), and a per-session opener that caps waiting creates, - hands a late stream to the next waiter and orders by priority (bounds - everything, but [L] and beyond this goal). + callers must decide whether to retry it), and a per-session opener that + caps waiting creates, hands a late stream to the next waiter and orders by + priority (bounds everything, but [L] and beyond this goal). - A request that has waited for a slot past about 10 s logs a `console.warn` once and keeps waiting, so a peer that never grants credit (a limit of zero, or slots held forever) shows up for whoever debugs it instead of stalling From 7ac094c2c39d2b3467056349498bc11b35b9b1b0 Mon Sep 17 00:00:00 2001 From: OneTooMany Date: Wed, 7 Oct 2026 17:23:19 +0200 Subject: [PATCH 5/5] quest: keep subscribe's TRACK_INFO under the setup deadline in js-stream-slot-wait Co-Authored-By: Claude Opus 5.5 --- quest/m1/js-stream-slot-wait.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/quest/m1/js-stream-slot-wait.md b/quest/m1/js-stream-slot-wait.md index 64863ecd7ef..50a57a32782 100644 --- a/quest/m1/js-stream-slot-wait.md +++ b/quest/m1/js-stream-slot-wait.md @@ -62,10 +62,14 @@ Decided (2026-10-07, with OneTooMany): cancellable wait for its slot and no new answer deadline: - subscribe (lite TRACK and SUBSCRIBE opens, IETF draft 17): its existing answer deadline starts once the stream is open; the wait ends when demand - leaves or the session closes; - - track info and fetch (lite `#exchange`): no answer deadline today and none - added; the wait ends with whatever ends the request today (the fetched - group closing, the subscriber closing); + leaves or the session closes. On lite-05+ the answer is the TRACK_INFO + that subscribe reads through `#trackInfo` (SUBSCRIBE itself gets no + response), so that TRACK_INFO stays under the deadline, started once the + TRACK stream opens; the SUBSCRIBE open after it only waits. On older lite + drafts the answer is SUBSCRIBE_OK; + - standalone track info and fetch (lite `#exchange`, outside subscribe): no + answer deadline today and none added; the wait ends with whatever ends + the request today (the fetched group closing, the subscriber closing); - announce interest (lite) and SubscribeNamespace (IETF v16): long-lived, so no answer deadline ever; the wait ends when the interest is dropped. - Chrome's immediate rejection stays terminal. Fix the text it makes stale: @@ -88,7 +92,10 @@ Things to look out for: - `Stream.open` needs a mode that waits until cancelled rather than until a deadline; `Writer.tryOpen` already has a cancel. - On lite-05+ a subscribe opens the TRACK stream and then the SUBSCRIBE - stream; both opens wait, and only the answer is under the deadline. + stream; both opens wait, and only TRACK_INFO is under the deadline. Keep + [#5002](https://github.com/moq-dev/moq/pull/5002)'s handling of a deadline + that fires mid-setup: the TRACK stream is reset, and a SUBSCRIBE stream + that opens afterwards is reset with nothing written. - On IETF drafts 14-16 requests ride the control stream and need no stream credit; only real opens (draft 17, v16 SubscribeNamespace) are affected. - Demand churn can still add waiting creates: each time demand leaves while @@ -104,7 +111,9 @@ waiting past `OPEN_TIMEOUT_MS` with no response deadline involved, and logs one warning; a watch-like retry loop over several deadlines leaves at most one waiting create; a freed slot lets the waiting create carry the SUBSCRIBE and the track delivers; a stream that -opened but got no answer still fails with `ControlTimeout`; demand leaving +opened but got no answer still fails with `ControlTimeout`, including a +lite-05+ subscribe whose TRACK stream opens but whose TRACK_INFO never +comes, while one whose TRACK open waits for credit doesn't; demand leaving during the wait resets the late stream; repeated leave and return cycles while slots stay held leave one queued create per cycle, no more. Cover lite and IETF draft 17, and a fetch and an announce interest whose opens wait.