Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 28 additions & 33 deletions quest/m0/qmux-credit.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,34 @@ within the close bound. Both hold on the 0.5 line that

## Plan

Facts from moq-dev/web-transport `rs/qmux/src/session.rs` (0.5.1 and main):

- Credit returns only through `RecvStream::report_consumed` on reads.
`Drop for RecvStream` sends STOP_SENDING and returns stream-count credit,
but never consumes bytes still buffered or queued in `inbound_data`.
- On STOP_SENDING the writer removes the recv entry, so later STREAM data is
dropped before the connection-credit check, and a later RESET_STREAM
returns early, so its final-size gap is never consumed. The peer counts all
of it against MAX_DATA.
- A new stream's entry is inserted only after `accept_uni`/`accept_bi` hands
it over, so a stream dropped in that window leaves a stale entry that keeps
charging the connection window.
- `close()` queues APPLICATION_CLOSE and marks the session closed at once. A
writer that is mid-write treats that as interrupted and drops the frame.
0.6 made `close()` idempotent and keeps the first reason, but not the order.

Work:

- Consume credit for unread bytes on drop, for STREAM data and the RESET
final-size gap after STOP_SENDING (keep enough of a retired stream's state
to account for its final size), and close the accept gap.
- Mark the session closed only once the writer has sent the close frame, with
a bound so a stalled transport still drops.
- Tests in `rs/qmux`: a session that drops many unread streams keeps
delivering past its initial window, and a peer reads the close code after a
close issued mid-write.
- Release on both lines (0.5.x after 0.5.2, and 0.6.x), then bump
`main`'s pin to that 0.5.x. `main` stays on 0.5: 0.6 needs
web-transport-trait 0.5, a breaking change that belongs on `dev`, which
picks up 0.6.x.

Why m0: the WebSocket fallback and the planned edge-to-core `tls://` links
both run on qmux, and MoQ drops streams constantly.
The source fixes are prepared as upstream drafts:

- [0.6 line](https://github.com/moq-dev/web-transport/pull/412), targeting `main`.
- [0.5 line](https://github.com/moq-dev/web-transport/pull/413), targeting
`qmux-v0.5.x` and retaining web-transport-trait 0.4.

Both return unread connection credit on stop/drop, retain stopped stream
accounting through FIN/RESET, and register the first receive frame before
publishing its frontend. Shared stream-count ownership bounds retained state.
The writer drains the first requested close before publishing teardown, with a
one-second bound including any in-flight write. Paused-time regressions cover
these paths, plus byte-stream peers across drafts 00, 01, and 02.

The two end-to-end regressions fail on unmodified qmux 0.5.2. Focused suites pass
on both fixes: 189 tests on 0.6 and 181 on 0.5, including doctests. Upstream CI
still needs to finish; these are draft PRs, not released fixes.

Remaining work:

- Merge the upstream fixes after review and CI.
- Publish patched 0.5.x newer than 0.5.2 containing #413, and patched
0.6.x newer than 0.6.2 containing #412.
The upstream release workflow only runs on `main`; the 0.5 release needs the
maintainer's release process.
- Bump `main`'s current 0.5.2 pin to the released 0.5 fix and validate the
WebSocket fallback. Update `dev` to the released 0.6 fix. Keep `main` on 0.5,
since web-transport-trait 0.5 is a breaking change reserved for `dev`.
- Delete this quest only after both release and pin steps are complete.

Public API: none. Wire: none.

Expand Down
Loading