Skip to content

fix(tokio): retain token grants through connection drains - #6859

Merged
kixelated merged 3 commits into
mainfrom
quest/m1/auth/drain-token
Oct 26, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m1/auth/drain-token

Conversation

@kixelated

@kixelated kixelated commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Connection::close() stops the reconnect task before draining its sessions. That drops configured tokens and aborts their auth handle, so a token-only publication with data still in flight ends Unauthorized.

Approach

Retain the loop's shared state and token holder through both session drains. A weak reference keeps ordinary task teardown unchanged; cancelling close also releases the retained owner. Extend the existing QUIC drain test with a token-only grant and a transfer spanning multiple congestion windows. Remove the completed quest.

Impact

  • No public API shape or wire changes. Graceful close keeps token grants presented until its sessions finish draining.

Alternatives

Retaining only the auth handle would still drop the configured tokens. A one-packet test passed unchanged, so the test keeps enough data in flight to expose the premature withdrawal.

Validation

  • Reproduced before the fix: recv_group failed with Stream(Unauthorized).
  • The same drain test passes with the fix.
  • Rust formatting and quest check --base origin/main pass.
  • just ci passes, including all 5,280 selected Rust tests (75 skipped by the CI profile).

Follow-ups

None in this change. Validation loads the Nix environment once and disables its repeated child-shell startup hook; that hook otherwise grows the environment until mbx cannot launch Cargo.

(Written by GPT-6)

kixelated and others added 3 commits October 25, 2026 22:51
Co-Authored-By: GPT-6 <noreply@openai.com>
Co-Authored-By: GPT-6 <noreply@openai.com>
@kixelated kixelated changed the title Rust keeps tokens through a drain fix(tokio): retain token grants through connection drains Oct 26, 2026
@kixelated
kixelated marked this pull request as ready for review October 26, 2026 06:33
@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

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 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 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: 4b829abf-b71b-4320-a833-dd572624f08f
Commits

Reviewing files that changed from the base of the PR and between f6d0ace and 9203951.

Files selected for processing: 4
  • quest/m1/auth/README.md
  • quest/m1/auth/drain-token.md
  • rs/moq-tokio/src/connection.rs
  • rs/moq-tokio/tests/integration/backend.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

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T06:35:04.495949Z 9203951 Draft marked ready
ℹ️ 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 kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by review (OpenAI)

Reviewed commit: 9203951

No actionable bugs found. Retaining both Shared and the token Holder through the current and predecessor drains addresses the ownership problem without changing the public API or wire format. The weak task reference avoids extending ordinary teardown, and retaining only the auth handle would not preserve configured token registrations. The expanded token-only, multi-window transfer test exercises the relevant failure rather than merely a successful close.

Verification: static inspection of the diff, surrounding close/abort lifecycle, token-holder ownership, session drain semantics, and regression test. I did not run tests or builds; cancellation and concurrent-close paths were inspected, not executed.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Landing summary: took over the stale quest:ready hold; no changes pushed.

  • Head 92039512eb8ac97a706f15a639a85cfc12af20e7 has a clean Codex review (thumbs up) and the other automated review found nothing actionable.
  • Merge state is clean and quest check --base origin/main passes.
  • quic_client_close_drains_finished_track passes locally in 0.09s, so the larger 64 KiB payload does not crowd the drain deadline.
  • No decisions outstanding. moq-dev/moq#6834 also edits rs/moq-tokio/src/connection.rs and quest/m1/auth/README.md, so whichever lands second resolves the overlap.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 97a6693 Oct 26, 2026
11 checks passed
@kixelated
kixelated deleted the quest/m1/auth/drain-token branch October 26, 2026 21:17
kixelated added a commit that referenced this pull request Oct 26, 2026
Resolve rs/moq-tokio/src/connection.rs against #6859: the loop-owned token Holder now lives in Running, built from the connection's Tokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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