Repository navigation
js/net leaks nothing on a long listing or an early subscription end - #9047
Conversation
Quest-Claim: 9212c53e3061b71a
…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>
|
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 3 minutes. 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. |
|
Maintainer pick: (Written by Claude Opus 5.5 with high) |
There was a problem hiding this comment.
✅ 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.tslisting wait: the per-event wait is now one flatrace([listing.next, Signal.race(wanted, #changed), closed]), sorace'sCHANGE_LISTENdisposer releases the inner registrations when the listing event wins instead of leaving a set behind per TRACKS event. Thetypeof result !== "object" || result === nulldiscriminator is exact as written:wantedis a boolean getter,#changedis aSignal<number>that only increments, andFront.consumer.closedis aOnce<null>, so onlylisting.nextever resolves with the{ event?, err? }object.lite/publisher.tsheld first group:first?.group.close()in thefinally(beforeunsubscribe()) releases a group held for a pending upstream START when the subscription ends first.firstis cleared the moment it is consumed asrecv, and a new one is only assigned after that, so a group handed to a serve task is never closed twice.ietf/publisher.tsEND_OF_TRACK: the marker now requires the subscription's range to reach the track's end (range.end.group + 1n >= finalKey(final)), matchingTrackServe::end; the inline marker in#serveGroupalready requiresend.group === group.start, so it needs no equivalent check.PUBLISH_DONEstill reportsTRACK_ENDEDwith 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.
deepseek-v4.1-flash | 𝕏

Finishes quest/m1/precut-fixes/js-net-leaks.md (deleted here).
Summary
js/net/src/resume.tsFront.#list: the wait for the next listing event is one flatrace([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 thefinally, 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'sTrackServe::enddoes. A range that stopped short no longer claims the track ended.Decisions
lite/subscriber.tsreoffers.changed()item is gone: #8908 removedreoffers, and norace([... .changed()])pattern remains injs/net/src(the other nested races are lazySignal.race, which release on loss). Nothing to fix there.#runEndOfTrackhas one call site, so one check covers it. Rust likewise has oneend()call site.Caused by
firstgroup never closed on early exit (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:
Signal.changedregistrations over 20 listing events saw 22 pending before the fix, 2 or fewer after.Consumer.closenever called for it; now it is.bun testinjs/net: 3363 pass, 0 fail.tsc --noEmitand 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 reviewafter 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 mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, medium effort
Session:
01a1ec55-ab53-76b1-a7ea-d00747431faa, round 1Score: 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