Repository navigation
fix(net): session auth replies revoke and stay bounded - #8198
Conversation
Quest-Claim: 5fafc03227cf6b55
An AUTH_OK the driver cannot encode now withdraws its grant from the session's scope along with the AUTH_ERROR that replaces it. A newer reply replaces a grant still queued, so a peer withholding stream credit holds at most one. Tokens::set withdraws a replaced token at once unless it was granted, so sets during a failing backend never pile up retrying streams. Handing the request queue to a new acceptor refuses the queued tokens after releasing the handle's lock, which refusing takes again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A replaced token keeps the grant wide only while it holds a grant on some session, not by its first answer. The JS IssuedGrant replaces a queued grant rather than chaining another write, and Held withdraws a replaced token that holds no grant at once, through an internal Handle.present that returns the credential before its answer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pending.held reports a grant on any session the handle backs, so a token still granted on a session draining after a GOAWAY keeps the grant wide until its replacement answers, as Rust's State::hold does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou'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 35 seconds. View limit details
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. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed head 246ad5e.
No actionable findings. Revoking the enforced grant when a reply cannot be encoded, coalescing unsent updates, and dropping queued requests outside the handle lock address the underlying state and resource problems. Token replacement now distinguishes a currently held grant from an unanswered/retrying presentation; checking every attached session preserves grants on draining sessions while their successor waits. The Rust and JS paths follow that distinction consistently.
Verification limits: GitHub-only static review of all ten changed files and surrounding issuance, withdrawal, token rotation and writer lifecycles. No tests, builds, race stress or protocol interoperability checks run. GitHub reports merge conflicts, so this is not a claim of merge readiness. Rechecked open/non-draft state, full head/base and published reviews immediately before posting.
There was a problem hiding this comment.
ℹ️ No critical issues — one documentation nit inline.
Reviewed changes
Reviewed the session-side auth bounds fix at head 3ba52cb24 (the only change since 246ad5ed5 is a merge of main), covering the Rust Issue/Pending lifecycle, both AUTH drivers, and the js/net counterpart.
- A refused AUTH_OK revokes its grant —
Issue::refused()clears the outbox andfinish()es, so the grantreply()recorded leaves the session scope; both drivers use it andoutbox/doneare now private. - Queued replies coalesce —
Issue::queuereplaces a still-queued grant and ignores replies afterfinish(), so a peer withholding stream credit holds one queued grant plus the in-flight write. - Replaced tokens withdraw promptly —
State::holdretires a replaced token only while some session's slot holds its grant, so refused/unanswered/retrying tokens no longer pile up AUTH streams. - Acceptor swap cannot deadlock —
Handle::requestscloses the replacedPendingafter releasing the state lock andPending::closedrops its requests after releasing its own, removing thehandle → pending → issue → handlecycle. - JS parity —
IssuedGrantcoalesces queued writes and clears its queue on revocation;Heldwithdraws non-granted replacements at once; the@internalHandle.present/Pendingexpose a token before its answer so a pending one can be withdrawn. - Quest completed —
quest/m1/auth-stream-bounds.mdis deleted with itsm1README bullet and no remaining references.
I verified the new Rust tests (105 auth::, 138 lite::publisher), the two JS suites (127 and 9), tsc --noEmit and the declaration build, all pass. The wire behavior stays within what drafts/draft-lcurley-moq-auth.md already allows: fewer AUTH_OKs is permitted, and AUTH_ERROR after AUTH_OK revokes.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior pullfrog review at 3ba52cb24, which is documentation-only.
- Restored
Token's doc comment —03e1aab7dmoved/** A token the application added to a {@link Handle} ... */back directly aboveclass Token, so the new@internal Pendingblock documents onlyPendingandTokenis documented again. This resolves the one nit from the previous review.
The merge commits (3ba52cb24, 82eeb6ab9) carry no PR-side changes beyond the base branch.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Completes quest/m1/auth-stream-bounds.md: moq-net's session-side auth keeps four promises it left to callers.
Changes
An AUTH_ERROR revokes its grant. When an AUTH_OK is too large to encode, both drivers (
lite/publisher.rs,ietf/auth.rs) send AUTH_ERROR and now callIssue::refused(). That clears the outbox and callsfinish(), so the grantreply()recorded leaves the session's scope. Before, they setdone = truedirectly and the grant kept admitting requests.Issue::outboxandIssue::doneare now private, so a driver can no longer end a stream withoutfinish().Queued replies are bounded.
Issue::queuereplaces a grant that is still queued (the peer never saw it) instead of appending. The app'sIssued::updateand the default acceptor's re-sent grants both go through it, so a peer that withholds stream credit holds at most one reply.queuealso ignores replies once the stream is done, so the default acceptor cannot write an AUTH_OK after the AUTH_ERROR.Replaced tokens are withdrawn even when never answered.
State::holdkeeps a replaced token presented (retiring) only while it holds a grant on some session. A token that was refused, never answered, or is still retrying adds nothing to the grant, so it is withdrawn at once. RepeatedTokens::setcalls while a backend fails transiently no longer pile up retrying AUTH streams.Swapping the acceptor cannot deadlock.
Handle::requestsnow takes out the earlier queue under the state lock and closes it after releasing the lock.Pending::closetakes the queuedRequests out before dropping them. Dropping a queued AUTH-tokenRequestrefuses it, and refusing takes the handle's lock again.JS counterpart (
js/net).IssuedGrant.updatereplaces a grant still waiting to be written instead of chaining another write, and a revocation replaces it too.Heldwithdraws a replaced token that holds no grant at once. It uses a new@internalHandle.present, which returns the credential before the peer answers (addnow wraps it), so a pending token can be withdrawn. JS has no session scope built from issued grants, andrequests()cannot be taken twice, so the other two fixes have no JS counterpart.Each fix has a unit test that fails (or hangs, for the deadlock) on
main:a_refused_grant_leaves_the_scope,a_blocked_stream_queues_one_grant,an_unanswered_replacement_is_withdrawn_when_replaced,a_new_acceptor_refuses_the_queue_without_deadlock, plusa_token_granted_after_a_requests_answer_retires. JS: "grants issued while a reply is blocked replace the one still queued" and "a token replaced before its answer is withdrawn at once".Impact
No public API or wire change. Only crate-private items in
moq_net::authchanged, plus the@internalHandle.presentandPendingtype in@moq/net. On the wire, a peer now sees only the latest of several queued AUTH_OKs, and a refusal replaces a still-queued AUTH_OK instead of following it. Each AUTH_OK already replaced the last one, so the final state is the same.Choices made without asking
Overlap
moq-dev/moq#8063 only adds
Permitmethods toauth.rsand touches routing inlite/publisher.rs. It does not overlap this PR.Caused by
donewithout revoking the grant, and the acceptor swap closed the old queue under the handle's lockTokens::setkept unanswered replaced tokens retiring until every new token was answeredValidation
just check: passed.Models
Size: S
Implementer: Claude Code, claude-opus-5-5, medium effort
Implementer: Claude Code, claude-opus-5-5, low effort (iterate, XS)
🤖 Generated with Claude Code
(Written by Claude Opus 5.5 with medium effort)
Review
Rewritten by
quest reviewafter each round.01a1b9a1-e177-7e93-91aa-05e5a202ceec, round 1The authorization fixes appear consistent across Rust and JavaScript, with no actionable defects identified; builds and tests were not run, as instructed.