Skip to content

fix(net): release losing subscription signal waits - #6341

Merged
kixelated merged 1 commit into
mainfrom
codex/subscription-wait-ownership
Oct 22, 2026
Merged

kixelated merged 1 commit into
mainfrom
codex/subscription-wait-ownership

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Problem

Each received group wakes the browser Lite subscriber's update loop. Its separate changed() promises leave listeners attached to the quiet subscription and wanted-group signals after losing the race. With unchanged demand, those registrations grow for the lifetime of the subscription.

Reproduced through the real subscriber with a controlled transport: 50 single-frame groups increased the three observed listener counts from [1, 2, 1] to [51, 52, 1] on Lite 05/06 and [52, 53, 1] on Lite 07.

Approach

Reuse Signal.race so each wake cancels the losing source registrations. The outer race also cancels that wait when the track or stream closes. Regression tests count source registrations across group arrivals and verify complete cleanup on unsubscribe, peer reset, and session shutdown for Lite 05/06/07.

Impact

  • Public API: unchanged.
  • Wire format and subscription messages: unchanged.

Alternatives

Keeping each promise alive until its own signal changes retains work from obsolete waits. The existing cancellable primitive handles ownership without another listener mechanism or resource cap.

Validation

  • Regression tests failed before the fix with the counts above and pass after it.
  • Subscriber and retention suites: 100 passed.
  • just ci: passed, including 2,599 net tests and affected downstream suites.
  • Audit baseline: 377 native cancellation, credit, abort, retention, drop, expiry, and close tests passed.

Follow-ups

None introduced. Checked existing audit work: moq-dev/moq#5878, moq-dev/moq#6332, and moq-dev/moq#6311 own other memory/lifetime concerns. moq-dev/moq#6305 measures subscription update traffic and does not fix these source registrations.

(Written by GPT-6)

Co-Authored-By: GPT-6 <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 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: b0c34308-552f-49e9-a9e7-7262e424f33b
📥 Commits

Reviewing files that changed from the base of the PR and between 1f5caa7 and 2cd8dd6.

📒 Files selected for processing: 2
  • js/net/src/lite/subscriber.test.ts
  • js/net/src/lite/subscriber.ts
  • 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 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-22T16:26:45.618824Z 2cd8dd6 PR opened
ℹ️ 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

Copy link
Copy Markdown
Collaborator Author

Queued: Codex gave this exact head a thumbs-up, CI is green, and quest check passes against current main. No API or wire change.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 38c58df Oct 22, 2026
9 checks passed
@kixelated
kixelated deleted the codex/subscription-wait-ownership branch October 22, 2026 19:53
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