From 275bd1b736ca27c375290479ae2809c29e92dc8e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 14 Oct 2026 14:46:20 -0700 Subject: [PATCH 1/2] quest: plan the WebSocket follow-ups from #426 Bound a silent WebSocket peer with handshake_timeout (a0) and advertise only a record size the WebSocket accepts (a1). Co-Authored-By: Claude Opus 5.5 --- quest/a0/README.md | 1 + quest/a0/qmux-ws-handshake-timeout.md | 11 +++++++++++ quest/a1/README.md | 1 + quest/a1/qmux-ws-record-size.md | 11 +++++++++++ 4 files changed, 24 insertions(+) create mode 100644 quest/a0/qmux-ws-handshake-timeout.md create mode 100644 quest/a1/qmux-ws-record-size.md diff --git a/quest/a0/README.md b/quest/a0/README.md index 214241e6..92f20d20 100644 --- a/quest/a0/README.md +++ b/quest/a0/README.md @@ -15,3 +15,4 @@ The Required list is ordered by priority. Independent children may proceed concu - [WASM datagram closure](/quest/a0/wasm-datagram-closure.md) - terminate cleanly closed writers - [Browser regression CI](/quest/a0/browser-ci.md) - execute Chromium harness - [QMux socket teardown](/quest/a0/qmux-socket-teardown.md) - release retained stats descriptors +- [WebSocket handshake timeout](/quest/a0/qmux-ws-handshake-timeout.md) - close sessions whose peer never sends parameters diff --git a/quest/a0/qmux-ws-handshake-timeout.md b/quest/a0/qmux-ws-handshake-timeout.md new file mode 100644 index 00000000..1b174191 --- /dev/null +++ b/quest/a0/qmux-ws-handshake-timeout.md @@ -0,0 +1,11 @@ +# [S] Bound a WebSocket QMux handshake + +## Goal + +A QMux session over WebSocket closes with an error when the peer never sends TRANSPORT_PARAMETERS within `Config::handshake_timeout`, for `ws::Client`, `ws::Server` and `ws::Upgraded` alike. Today a peer that completes the WebSocket upgrade and then stays silent holds the session open indefinitely. + +## Plan + +`Session::connect` and `Session::accept` bound the parameter exchange, but every ws builder starts through `Session::new`, which never waits for the peer's parameters. Arm the deadline inside the session started by `Session::new` and close the session with the same error `Session::connect` returns on timeout if the peer's TRANSPORT_PARAMETERS haven't arrived by then. This is the lowest layer that covers all three builders without an API change. Do not make `ws::Upgraded::connect`/`accept` async; that would break the API. Wire formats that exchange no transport parameters arm no deadline. Fold `Session::connect`/`accept`'s own timeout into the same mechanism if that simplifies things. + +Remove the "`handshake_timeout` does not apply" notes from the three `with_session_config` docs. Cover each builder on paused time. Main only; backport to `qmux-v0.5.x` only if moq asks. diff --git a/quest/a1/README.md b/quest/a1/README.md index 230afa6c..ebcc4968 100644 --- a/quest/a1/README.md +++ b/quest/a1/README.md @@ -13,6 +13,7 @@ The Required list is ordered by priority. Independent children may proceed concu - [Binding runtime coverage](/quest/a1/bindings/README.md) - independent language jobs - [Node idle configuration](/quest/a1/node-idle/README.md) - typed native input and Node options - [Native client composition](/quest/a1/native-client-config.md) - configured native setup with generic use +- [WebSocket record size](/quest/a1/qmux-ws-record-size.md) - advertise only what the socket accepts - [Response headers](/quest/a1/response-headers.md) - preserve success and rejection metadata - [Current architecture docs](/quest/a1/docs-current.md) - repair stale workspace descriptions - [Package selection](/quest/a1/package-selection.md) - verified comparison and selection guide diff --git a/quest/a1/qmux-ws-record-size.md b/quest/a1/qmux-ws-record-size.md new file mode 100644 index 00000000..82c63bca --- /dev/null +++ b/quest/a1/qmux-ws-record-size.md @@ -0,0 +1,11 @@ +# [S] Advertise a record size the WebSocket accepts + +## Goal + +`ws::Client` and `ws::Server` never advertise a `max_record_size` larger than their WebSocket will accept, so a peer that sends a record within the advertised limit can't trip tungstenite's frame limit and kill the session. + +## Plan + +Each QMux record is one WebSocket message, so tungstenite's `max_frame_size`/`max_message_size` (16 MiB frame by default) caps the usable record size. Give `ws::Server` a `with_config(WebSocketConfig)` matching `ws::Client`'s and pass it to `accept_hdr_async_with_config`. Both builders then advertise `min(max_record_size, the WebSocket's limit)`; the datagram limit already derives from the record size. Clamping keeps the advertised ceiling truthful without failing a connect. + +`ws::Upgraded` wraps any tungstenite `Sink`/`Stream`, so qmux can't see its limit; keep its `with_session_config` note telling callers to stay within it. Update the Client and Server docs to describe the clamp. Main only; backport to `qmux-v0.5.x` only if moq asks. From 9c29758ef9a5c1e23603daf4552607e468981c1e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 14 Oct 2026 15:08:34 -0700 Subject: [PATCH 2/2] quest: reject WebSocket limits below the record minimum Co-Authored-By: Claude Opus 5.5 --- quest/a1/qmux-ws-record-size.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quest/a1/qmux-ws-record-size.md b/quest/a1/qmux-ws-record-size.md index 82c63bca..456ab56d 100644 --- a/quest/a1/qmux-ws-record-size.md +++ b/quest/a1/qmux-ws-record-size.md @@ -6,6 +6,6 @@ ## Plan -Each QMux record is one WebSocket message, so tungstenite's `max_frame_size`/`max_message_size` (16 MiB frame by default) caps the usable record size. Give `ws::Server` a `with_config(WebSocketConfig)` matching `ws::Client`'s and pass it to `accept_hdr_async_with_config`. Both builders then advertise `min(max_record_size, the WebSocket's limit)`; the datagram limit already derives from the record size. Clamping keeps the advertised ceiling truthful without failing a connect. +Each QMux record is one WebSocket message, so tungstenite's `max_frame_size`/`max_message_size` (16 MiB frame by default) caps the usable record size. Give `ws::Server` a `with_config(WebSocketConfig)` matching `ws::Client`'s and pass it to `accept_hdr_async_with_config`. Both builders then advertise `min(max_record_size, the WebSocket's limit)`; the datagram limit already derives from the record size. Clamping keeps the advertised ceiling truthful without failing a connect. The one exception is a WebSocket limit below the QMux minimum (`DEFAULT_MAX_RECORD_SIZE`): the peer rejects that as a TRANSPORT_PARAMETER error, so `connect`/`accept` return an error locally instead of advertising it. `ws::Upgraded` wraps any tungstenite `Sink`/`Stream`, so qmux can't see its limit; keep its `with_session_config` note telling callers to stay within it. Update the Client and Server docs to describe the clamp. Main only; backport to `qmux-v0.5.x` only if moq asks.