Skip to content

fix(qmux): bound WebSocket record advertisements - #498

Merged
kixelated merged 6 commits into
mainfrom
quest/a1/qmux-ws-record-size
Nov 8, 2026
Merged

kixelated merged 6 commits into
mainfrom
quest/a1/qmux-ws-record-size

Conversation

@kixelated

@kixelated kixelated commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

QMux could advertise a 32,764-byte record limit while tungstenite rejected a 16,383-byte frame. Both WebSocket builders now clamp the QMux01+ receive record size to their frame and message limits after subprotocol negotiation and before creating a session, so the wire advertisement and receive path use the same effective bound. ws::Server::with_config(WebSocketConfig) applies the same socket configuration API as the client.

The regressions inspect actual QMux01/02 transport parameters from both builders, cover default/custom/unlimited WebSocket limits and datagram bounds, deliver exact-limit records (including fragmented messages), and verify local errors below the protocol minimum without advertising invalid parameters, and preserve QMux00/legacy setup with ignored record limits. The completed quest and its parent link are removed.

API and wire compatibility

  • Adds ws::Server::with_config; no existing signatures or wire formats change.
  • Oversized configured advertisements are reduced to the WebSocket's receive limits. Existing default session limits are unchanged.
  • Effective record sizes below 16,382 bytes return the existing Error::TransportParameter after WebSocket negotiation, before QMux parameters are sent, after sending a WebSocket Close explaining the configuration error. Bare-frame versions continue to ignore record limits. ws::Upgraded remains the caller's responsibility because its generic socket does not expose receive limits.

Decisions

  • Reuse Error::TransportParameter for invalid local record limits rather than adding another public error variant.
  • Apply the record clamp and floor only after negotiating QMux01/02, preserving the older bare-frame versions. Preserve each stored builder config for reuse.
  • Keep the configured subprotocol offers and acceptance policy. The approved Plan calls for an error when a negotiated record-framed version has an unusable limit; silently selecting an older protocol would change that behavior.
  • Main only; no 0.5 backport.

Validation

  • Original mechanism reproduced: advertised 32,764 bytes; frame limit 16,382; a 16,383-byte record closed with tungstenite Capacity.
  • The wire-advertisement regression fails without the clamp: 33,554,432 advertised versus 16,777,216 expected with default WebSocket limits.
  • nix develop --command just fix passed.
  • nix develop --command just test passed, including all four new regressions.
  • nix develop --command cargo test -p qmux --no-default-features --features ws --lib passed: 142 tests.
  • nix develop --command just check passed on this branch and unchanged main.
  • Installed Quest check --base origin/main passed: 41 documents.
  • Extra standalone-feature integration check nix develop --command cargo test -p qmux --no-default-features --features ws fails identically here and on unchanged main 7cc85bd28dabca12e9a7330cddc525d884066758: rs/qmux/tests/stats.rs:3 unconditionally imports transport::Stream, which requires tcp or Unix uds. The repository harness is unchanged.

Review

Claude Code, claude-opus-5-5, medium effort, round 2 of the revised design session reviewed head 94c66d73e89db684d474af2c70a97647a748ea77 against origin/main. No findings remain.

  • Fixed the initial compatibility finding by checking record limits only after negotiating QMux01/02; bare-frame setup has regression coverage.
  • Fixed the bare-frame documentation finding by stating the caller's responsibility on both builders and in the README.
  • Fixed the local teardown finding with an explanatory WebSocket Close and a wire-level assertion; fixed README wrapping.
  • Refuted subprotocol filtering: the approved Plan explicitly requires a local error below the record minimum. Negotiating a different version would change that selected behavior. The reviewer accepted this response.
  • Installed Quest rejected combining --new with --responses; the required new design session ran with --new, and the next round accepted the written finding responses.

Suggested follow-up

Gate the byte-stream stats integration test on its transport features so the standalone WebSocket integration suite compiles. This existing test-feature mismatch is outside the record-size fix.

(Written by GPT-6.1 Sol with xhigh)

kixelated and others added 2 commits November 7, 2026 04:06
Clamp session record limits to the configured WebSocket frame and message bounds before establishment. Accept the same WebSocketConfig on the server and reject limits below the QMux minimum locally.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Design change: apply record-size clamping and the minimum check after WebSocket subprotocol negotiation, only for record-framed drafts (QMux01+), before a QMux session can send transport parameters. The local review found that checking before negotiation rejected previously valid QMux00 and legacy sessions whose record-size setting is ignored. Compatibility regressions now exercise both builders on those versions with small WebSocket limits and max_record_size = 1000. This preserves their existing bare-frame behavior while keeping record-framed advertisements truthful.

(Written by GPT-6.1 Sol with xhigh)

Apply record-limit validation after negotiating a record-framed draft, before a QMux session can advertise parameters. Keep QMux00 and legacy setup compatible when the configured record limit is ignored.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Review response: the local review suggested filtering QMux01/02 out of negotiation when a configured record limit is too small. The approved quest Plan explicitly chooses a local connect/accept error for that configuration. I am preserving that behavior and the configured subprotocol policy, with a WebSocket Close that explains the local error before any QMux parameters are sent. The older bare-frame versions retain their existing configuration behavior, and their separate frame-size responsibility is now documented on both builders and in the README.

(Written by GPT-6.1 Sol with xhigh)

Send a WebSocket Close before returning a local record-limit error and document the caller's frame-size responsibility for older wire formats.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
@kixelated kixelated changed the title Advertise a record size the WebSocket accepts fix(qmux): bound WebSocket record advertisements Nov 7, 2026
@kixelated
kixelated marked this pull request as ready for review November 7, 2026 12:31
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1ab75061-109d-409a-97ef-d075eee0b3b5
Commits

Reviewing files that changed from the base of the PR and between 85270d0 and 7938d16.

Files selected for processing: 5

  • quest/a1/README.md
  • quest/a1/qmux-ws-record-size.md
  • rs/qmux/README.md
  • rs/qmux/src/error.rs
  • rs/qmux/src/ws.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T17:24:19.493226Z 7938d16 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary:

  • Merged main (fix(qmux): enforce a shared handshake deadline #482's shared handshake deadline, feat(quinn)!: accept caller-provided transport configuration #489, and others) into this branch at 7938d16. Resolved conflicts in rs/qmux/README.md (kept both the record-limit and the handshake_timeout paragraphs) and rs/qmux/src/ws.rs (kept this PR's code and record-limit docs, took main's wording that handshake_timeout now applies to WebSocket sessions, and kept both test modules). cargo test -p qmux, just fix, just check, and quest check pass. Codex reviewed the new head and found nothing.
  • The earlier build failure was web-transport-quiche's a_finished_poll_releases_the_poller (tests/poll.rs:203). It's a flaky test on main that this PR doesn't touch, and it also failed on test(swift): exercise native host bindings in PR CI #496. The re-run passed. Likely mechanism: kio's WaiterList::wake upgrades each weak waiter to a strong Arc before calling wake_by_ref. On the multi-thread runtime, the test can see Ready and check strong_count while the driver thread is still inside that wake, so the count is briefly 2. Left as a follow-up.
  • Main's later commits (including fix(qmux): reject send controls for unopened local streams #484) merge cleanly. The merge queue tests the combined result.

(Written by Claude Opus 5.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant