Skip to content

fix(net): release AUTH enforcement's reactions on the session close - #6386

Merged
kixelated merged 6 commits into
mainfrom
quest/m1/release-audit/auth-listeners
Oct 24, 2026
Merged

kixelated merged 6 commits into
mainfrom
quest/m1/release-audit/auth-listeners

Conversation

@kixelated

@kixelated kixelated commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

enforceGrant (js/net/src/auth_session.ts), which closes a publishing browser session that advertises outside its in-band AUTH grant, raced the session's closed promise with native Promise.race on every broadcast-table or grant change. A native race cannot drop its reaction on the loser, so each change left one reaction on a promise that lives as long as the session. A new test counts 1,001 reactions after 1,000 changes. Its authorization wait (auth.ready) also ignored the close. Completes Release AUTH terminal listeners.

Approach

  • The loop uses race from @moq/signals, the repository's listener-releasing race, so one reaction on closed serves every wake.
  • An authorization wait ends with the session through one AbortController that the close aborts once. ready removes its abort listener after each wait, so this adds no reaction per wait, which passing until: () => closed would.
  • Other repeated races over a lifetime promise, fixed the same way:
    • lite/publisher.ts: the drain loop raced the subscription's ended once per batch of drops.
    • ietf/subscriber.ts: each legacy zero-prefix announce wait chained a fresh .catch onto the session's closed, which stayed attached after the consumer ended.
  • Left alone: single-shot races, and connect.ts, whose races are over promises created per connect attempt.

Impact

Public API and wire: none.

Validation

New auth_session.test.ts, which counts the reactions each promise receives via Promise.prototype.then:

  • 1,000 table changes over 2 and over 64 live broadcasts leave fewer than 10 reactions on any promise; main leaves 1,001 on closed.
  • A session that closes during an authorization wait ends enforcement promptly and does not close the session again.

Suites:

  • bun test in js/net: 2,636 pass, and repeated full runs pass.
  • just check: two failures in tests this PR does not touch:
    • @moq/hang's libav test-order failure, already on main and fixed in moq-dev/moq#6382.
    • moqt-22 > a request waits for its token and survives union renewal, which failed once under the full parallel check. It passed 5 isolated runs and 3 full js/net runs, here and on main. This looks like a load-dependent flake.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EeyiEy5FWz3z44DYZVo7vU

(Written by Claude Opus 5.5)

kixelated and others added 2 commits October 22, 2026 13:50
`enforceGrant` raced the session's close with native `Promise.race` on
every table or grant change, so each change left one reaction on the
session-lifetime `closed` promise until the transport closed: 1,000
changes left 1,001. An authorization wait also ignored the close.

Race with `@moq/signals` `race`, which drops its listener once decided,
and end an authorization wait through one AbortController the close
aborts. The same repeated race over a lifetime promise is fixed in the
lite publisher's drain loop and the IETF legacy announce wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EeyiEy5FWz3z44DYZVo7vU
@kixelated kixelated changed the title Release AUTH terminal listeners during session churn fix(net): release AUTH enforcement's reactions on the session close Oct 22, 2026
@kixelated
kixelated marked this pull request as ready for review October 22, 2026 20:57
@kixelated

Copy link
Copy Markdown
Collaborator Author

Outcome: the quest is complete and its file is deleted. AUTH enforcement now keeps O(1) reactions on the session close however much the table churns. It has no open decisions, so this is ready for review. In just check, two tests failed that this PR does not touch: the @moq/hang libav test-order failure (fixed in #6382), and one moqt-22 AUTH renewal test that I could not reproduce in 3 full runs here or on main.

(Written by Claude Opus 5.5)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-24T07:59:10.991581Z eed6cf7 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.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 1 minute.

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: 89569383-37b1-4d7e-94f0-407585793bda
Commits

Reviewing files that changed from the base of the PR and between f7a0dc6 and eed6cf7.

Files selected for processing: 6
  • js/net/src/auth_session.test.ts
  • js/net/src/auth_session.ts
  • js/net/src/ietf/subscriber.ts
  • js/net/src/lite/publisher.ts
  • quest/m1/release-audit/README.md
  • quest/m1/release-audit/auth-listeners.md

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ 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: 6e95d372-b2f0-4333-86db-2c4ad6f8ceff
📥 Commits

Reviewing files that changed from the base of the PR and between fe9bf01 and f7a0dc6.

📒 Files selected for processing: 6
  • js/net/src/auth_session.test.ts
  • js/net/src/auth_session.ts
  • js/net/src/ietf/subscriber.ts
  • js/net/src/lite/publisher.ts
  • quest/m1/release-audit/README.md
  • quest/m1/release-audit/auth-listeners.md
💤 Files with no reviewable changes: 2
  • quest/m1/release-audit/README.md
  • quest/m1/release-audit/auth-listeners.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Walkthrough

AUTH enforcement now passes a connection-close abort signal to auth.ready and uses the shared race helper for broadcast or grant changes. Tests cover promise reaction counts and cleanup when the session closes during authorization. The subscriber empty-prefix wait and publisher group-drain wait also use race. The AUTH listener release-audit entry and document were removed.

Priority: Low

Merge Risk: Minimal · up to f7a0d

The closure waits appear to retain their intended behavior without the reported listener buildup. No merge-blocking issue remains after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the main change: AUTH enforcement's race reactions on the session close are released. The PR replaces native Promise.race with the listener-releasing race from @moq/signals in enforceG…
Description check Passed The description states the problem (native Promise.race leaves one reaction per change on the long-lived closed promise, and auth.ready ignores close), the approach (race from @moq/signals, AbortContr…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: AUTH enforcement's race reactions on the session close are released. The PR replaces native Promise.race with the listener-releasing race from @moq/signals in enforceGrant, adds an AbortController for authorization waits, and applies the same fix to lite/publisher.ts and ietf/subscriber.ts. The title is specific to the core change and matches the objectives.

Full details: Description check

Explanation

The description states the problem (native Promise.race leaves one reaction per change on the long-lived closed promise, and auth.ready ignores close), the approach (race from @moq/signals, AbortController for authorization waits, and the publisher and subscriber fixes), impact, and validation (new test counts reactions, bun test results, and two just check failures). It is directly related to the changeset.

✨ Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • 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 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 730c98f7ac

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread js/net/src/auth_session.ts Resolved
Ending enforcement because the session closed during an authorization
wait returned without disposing the table and grant callbacks it had
registered for that pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EeyiEy5FWz3z44DYZVo7vU
@kixelated

Copy link
Copy Markdown
Collaborator Author

@codex review

(Written by Claude Opus 5.5)

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 09055ac3f7

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…t/auth-listeners

# Conflicts:
#	quest/m1/release-audit/README.md
@kixelated

Copy link
Copy Markdown
Collaborator Author

Merged main and resolved the quest/m1/release-audit/README.md conflict by taking main's Required-section wording; this PR's removal of the auth-listeners entry stands. The Codex P2 (dispose on the abort path) was fixed in 09055ac and its thread is resolved. just check passed on the merged head (@moq/net 2,707 pass), and quest check --base origin/main is clean. Codex gave a thumbs-up on the final head. Enqueueing.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 24, 2026
# Conflicts:
#	quest/m1/release-audit/README.md
@kixelated
kixelated added this pull request to the merge queue Oct 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 24, 2026
# Conflicts:
#	quest/m1/release-audit/README.md
@kixelated
kixelated enabled auto-merge October 24, 2026 07:56
@kixelated
kixelated added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit e24ac5a Oct 24, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m1/release-audit/auth-listeners branch October 24, 2026 09:24
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