Skip to content

js/net leaks nothing on a long listing or an early subscription end - #9047

Merged
moq-bot[bot] merged 2 commits into
mainfrom
quest/m1/precut-fixes/js-net-leaks
Nov 18, 2026
Merged

moq-bot[bot] merged 2 commits into
mainfrom
quest/m1/precut-fixes/js-net-leaks

Conversation

@kixelated

@kixelated kixelated commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m1/precut-fixes/js-net-leaks.md (deleted here).

Summary

  • js/net/src/resume.ts Front.#list: the wait for the next listing event is one flat race([listing.next, Signal.race(wanted, changed), closed]). Before, race([listing.next, wait()]) left the inner race's three registrations pending every time the event won, so a long listing grew them per TRACKS event.
  • js/net/src/lite/publisher.ts: the group held while the upstream START is pending (first) is closed in the finally, so a relayed filled group no longer keeps reading upstream for nobody when the subscription ends first.
  • js/net/src/ietf/publisher.ts: END_OF_TRACK is sent only when the subscription's range reaches the track's end (range.end.group + 1 >= finalKey(end)), as Rust's TrackServe::end does. A range that stopped short no longer claims the track ended.

Decisions

  • The quest's lite/subscriber.ts reoffers.changed() item is gone: #8908 removed reoffers, and no race([... .changed()]) pattern remains in js/net/src (the other nested races are lazy Signal.race, which release on loss). Nothing to fix there.
  • "On release too" has no JS counterpart: #runEndOfTrack has one call site, so one check covers it. Rust likewise has one end() call site.
  • Two existing ietf tests asserted the bug (END_OF_TRACK after a range that stopped short of the track's end, bounded to group 0 and group 3). They now expect no marker and one fewer stream in PUBLISH_DONE.

Caused by

  • moq-dev/moq#6158 - listing wait nested a race, leaking registrations per event (found by audit)
  • moq-dev/moq#6206 - held first group never closed on early exit (found by audit)
  • moq-dev/moq#5283 - ietf END_OF_TRACK ignored the subscription's range, unlike Rust (found by audit)

Public API and wire

None to the API. Wire: on moq-transport (IETF), a subscription whose range stopped short of the track's end no longer receives END_OF_TRACK (and PUBLISH_DONE's stream count is one lower); it ends with PUBLISH_DONE alone, as the Rust publisher already does.

Validation

Each fix reproduced first:

  • Listing: a test counting live Signal.changed registrations over 20 listing events saw 22 pending before the fix, 2 or fewer after.
  • Lite publisher: a test with a group held for a pending START and the subscribe stream closed saw Consumer.close never called for it; now it is.
  • IETF: the two existing tests asserting the marker failed with the check in place until corrected, and a new test covers a bounded range that reaches the end (marker still sent).

bun test in js/net: 3363 pass, 0 fail. tsc --noEmit and Biome clean. No wire change on lite, so no interop run needed; the ietf change only drops a marker the Rust side already does not send.

Follow-ups

None.

Models

Size: S
Implementer: Claude, claude-sonnet-5-5, unknown effort (arm B)

(Written by Sonnet 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 4afcc97

  • Base: origin/main at 61f8956

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1ec55-ab53-76b1-a7ea-d00747431faa, round 1

  • Score: 9/10, No actionable regressions were found; the cleanup and range-boundary changes appear sound, but builds and tests were not run as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 2 commits November 17, 2026 17:33
…tion end

- Front's listing races the event against the wait flat, so a won event leaves no
  registrations behind per event.
- The lite publisher closes a group held for the upstream START when the subscription ends first.
- The ietf publisher sends END_OF_TRACK only when the subscription's range reaches the track's end.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 18, 2026 01:47
@coderabbitai

coderabbitai Bot commented Nov 18, 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 3 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: 25077463-7cf1-464f-acf7-9ffba00b17e4
Commits

Reviewing files that changed from the base of the PR and between 0c14c87 and 4afcc97.

Files selected for processing: 7

  • js/net/src/ietf/publisher.test.ts
  • js/net/src/ietf/publisher.ts
  • js/net/src/lite/publisher.test.ts
  • js/net/src/lite/publisher.ts
  • js/net/src/resume.test.ts
  • js/net/src/resume.ts
  • quest/m1/precut-fixes/js-net-leaks.md
  • 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

@kixelated

Copy link
Copy Markdown
Collaborator Author

Maintainer pick: /quest-merge.

(Written by Claude Opus 5.5 with high)

@kixelated
kixelated enabled auto-merge November 18, 2026 01:56

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Approach: sound — each of the three defects is fixed where it is created (the race registration, the held group, the marker's range check) rather than papered over, and the IETF change mirrors Rust's TrackServe::end formula exactly.

Reviewed changes

  • resume.ts listing wait: the per-event wait is now one flat race([listing.next, Signal.race(wanted, #changed), closed]), so race's CHANGE_LISTEN disposer releases the inner registrations when the listing event wins instead of leaving a set behind per TRACKS event. The typeof result !== "object" || result === null discriminator is exact as written: wanted is a boolean getter, #changed is a Signal<number> that only increments, and Front.consumer.closed is a Once<null>, so only listing.next ever resolves with the { event?, err? } object.
  • lite/publisher.ts held first group: first?.group.close() in the finally (before unsubscribe()) releases a group held for a pending upstream START when the subscription ends first. first is cleared the moment it is consumed as recv, and a new one is only assigned after that, so a group handed to a serve task is never closed twice.
  • ietf/publisher.ts END_OF_TRACK: the marker now requires the subscription's range to reach the track's end (range.end.group + 1n >= finalKey(final)), matching TrackServe::end; the inline marker in #serveGroup already requires end.group === group.start, so it needs no equivalent check. PUBLISH_DONE still reports TRACK_ENDED with a stream count one lower when no marker stream opens, which is what Rust sends.
  • Tests: three cases reproduce the audited defects — pending listing registrations bounded across 20 TRACKS events (22 before), a held group closed when the subscribe stream ends, and END_OF_TRACK kept for a bounded range that reaches the end while dropped for the two ranges that stopped short. The two corrected IETF assertions now match the Rust publisher.

The quest deletion leaves no dangling references: no quest/ file or other doc names js-net-leaks. I ran bun test js/net/src (3362 pass, 0 fail, nothing skipped), tsc --noEmit -p js/net/tsconfig.json, and Biome on the changed files — all clean.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash | 𝕏

@moq-bot
moq-bot Bot added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 2afc94b Nov 18, 2026
12 checks passed
@moq-bot
moq-bot Bot deleted the quest/m1/precut-fixes/js-net-leaks branch November 18, 2026 02:15
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