Skip to content

fix(wasm): report None when no subprotocol was negotiated - #381

Merged
kixelated merged 1 commit into
mainfrom
claude/web-transport-wasm-trait-d63421
Aug 19, 2026
Merged

kixelated merged 1 commit into
mainfrom
claude/web-transport-wasm-trait-d63421

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

What

web_transport_wasm::Session::protocol() returned Some("") when no subprotocol was negotiated. It now returns None.

Why

The browser initializes WebTransport.protocol to "" when the server selects no subprotocol — the same sentinel WebSocket uses. We passed that straight through, but web_transport_trait::Session::protocol documents None as the "nothing was negotiated" answer, so the wasm backend was out of conformance with the trait it implements.

The practical cost lands on callers: a caller matching the result against its own protocol table sees Some("") and reads it as a peer choice, instead of falling back to negotiating a version over its own handshake.

This was already known downstream. Both moq adapters (rs/moq-wasm/src/transport.rs, rs/moq-ffi/src/transport.rs) carry a .filter(|p| !p.is_empty()) with a comment explaining the browser's sentinel. Those adapters exist to bridge to web-transport-trait and are slated for deletion now that this crate implements it natively (#369) — so the compensation has to move here or it gets deleted along with them.

Normalizing at the capture site in Session::new rather than in the getter keeps the inherent getter and both trait impls agreeing without each needing to know about "".

Testing

Added a harness case. connect in the harness offers no subprotocols, so the browser negotiates none — exactly the path that produced the sentinel.

Ran just harness against Chromium and the harness-server QUIC peer, both ways:

  • with the fix: 15 passed, 0 failed — protocol() returned None
  • with the fix reverted: 14 passed, 1 failed — protocol() returned Some("")

just check and just test both pass.

For reviewers

  • The doc touch on web-transport/src/wasm.rs is comment-only; the router already delegates to the inherent getter, so it inherits the fix.
  • No behavior change for a session that did negotiate a subprotocol.
  • Not a semver break in practice, but it does change an observable return value, and web-transport-wasm is already queued for a breaking 0.6.0 in chore: release #363.

(written by Opus 5)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@kixelated, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 14 minutes

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

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

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b751a19-4be5-431d-a04b-101cef2023fc

📥 Commits

Reviewing files that changed from the base of the PR and between 37cafb4 and 382918d.

📒 Files selected for processing (3)
  • rs/web-transport-wasm/examples/harness.rs
  • rs/web-transport-wasm/src/session.rs
  • rs/web-transport/src/wasm.rs

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

Comment @coderabbitai help to get the list of available commands.

@kixelated
kixelated enabled auto-merge (squash) August 19, 2026 22:55
`Session::protocol()` returned whatever the browser put on the
`protocol` property, and the browser reports `""` when no subprotocol
was selected. The trait contract says an unnegotiated protocol is
`None`, so callers matching the result against their own protocol table
saw `Some("")` and treated it as a peer choice rather than falling back
to negotiating over their own handshake.

Downstream adapters were already compensating with a
`.filter(|p| !p.is_empty())` on their side. Normalizing at the capture
site instead means the inherent getter and both trait impls agree
without each having to know about the browser's sentinel, and lets
those adapters be deleted rather than ported.

Covered by a harness case: `connect` there offers no subprotocols, so
the browser negotiates none. It fails with `Some("")` before this
change and passes with `None` after.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@kixelated
kixelated force-pushed the claude/web-transport-wasm-trait-d63421 branch from b57b5d9 to 382918d Compare August 19, 2026 23:06
@kixelated
kixelated merged commit 791f555 into main Aug 19, 2026
1 check passed
@kixelated
kixelated deleted the claude/web-transport-wasm-trait-d63421 branch August 19, 2026 23:28
@moq-bot moq-bot Bot mentioned this pull request Aug 19, 2026
This was referenced Sep 28, 2026
@moq-bot moq-bot Bot mentioned this pull request Oct 7, 2026
This was referenced Oct 14, 2026
This was referenced Oct 22, 2026
@moq-bot moq-bot Bot mentioned this pull request Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant