Repository navigation
fix(net): open JS SUBSCRIBE_TRACKS PUBLISHes only as stream credit admits - #6663
Conversation
Quest-Claim: f12d211316a21f24
…mits Mirror moq-net's run_listed_broadcast in @moq/net's #listBroadcast: stage one track per broadcast and open its PUBLISH stream only as the peer's credit admits, keep reading the listing for removals meanwhile, and have a FORWARD=1 listing read its next track only once the request stream took the last skip. The listing no longer uses the Limits request cap, so Limits.requests and Slots.hold are gone. untilAborted now observes the promise it drops when its signal is already aborted, which a peer resetting a PUBLISH during its write surfaced as an unhandled rejection. Co-Authored-By: Claude Opus 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 20 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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Merging e3f4ae9 with the maintainer's approval. The non-Grok review of this head is clean, every finding is fixed or answered, and the pre-land (Written by Claude Opus 5.5) |
|
Re-landing after the queue dropped it for a conflict with main. Merged origin/main (no rebase), resolving two conflicts:
The PR's own diff against main is unchanged by the merge. (Written by Claude Opus 5.5) |
Problem
A
@moq/netdraft-18+SUBSCRIBE_TRACKSlisting started a PUBLISH for every listed track up to theLimits.requestscap, skipping the rest, and queued every FORWARD=1 skip at once. What a peer could make us hold grew with the catalog, not with what it read. moq-dev/moq#6641 fixed this in moq-net. moq-dev/moq#6644 made@moq/qmuxhold stream credit until both halves of a bidi stream end, so credit now bounds open streams in JS too.Approach
#listBroadcastinjs/net/src/ietf/publisher.tsmirrors Rust'srun_listed_broadcast:#runPublishreceives the opened stream.pending. A removed staged track gives its stream to the next pending one.changedwhenever it takes one.Limits.requests. Since nothing else reads it,Limits.requests, the publisher's subscription counter, andSlots.holdare removed.The new tests also exposed a gap:
untilAbortedthrew on an already-aborted signal without observing the promise it dropped. A peer resetting a PUBLISH while its write was in flight then leftrequest.next()'s rejection unhandled. It now observes that promise.Tests (
js/net/src/ietf/subscribe_tracks.test.ts), each swept over catalogs of 4, 64 and 512 tracks. Both fail on the old code:a listing publishes only as credit admits, on every draft: a real@moq/qmuxpair over an in-memory socket, where the client grants 2 bidi streams and reads nothing. At most one stream open waits beyond the granted credit, and every track is PUBLISHed exactly once as refusals return credit. The old code had every remaining track waiting, which fails on the first catalog.a forwarding listing reads only as skips go out, on drafts 19 and 22: each skip's write is held. The listing reads at most the skips taken plus three: the one being written, the one queued, and SYNCED or the next read. The old code read the whole catalog up front.Impact
Limits,SlotsandPublisherare@internaland not exported from@moq/net. Listing PUBLISHes are no longer skipped (PUBLISH_BLOCKED on draft 18) past a request cap. They wait on stream credit instead, as in Rust.doc/concept/standard.mdnow states this for both languages.Decisions made without asking
Message.writefor PUBLISH_SKIPPED with a spy, which stands for a peer that stops reading.createBidirectionalStreamcan't be cancelled, so a stream that opens after its staged track went (and no pending track can take it) is reset at once. This is bounded to one per broadcast listing.untilAbortedfix is in this PR because the new test reaches it, and any real transport can reach it the same way.Checks
just check: passed.just ci: passed.just test interop --all: passed, except the known flake in quest/m1/test-flakes-2/interop-timestamp-gap.md:rust -> js-native-nodefailed once with an audio timestamp gap and passed on rerun, and the rerun then hit the same gap onrust-swapped -> js-native-node. Both are moq-lite paths, which don't touch the changed listing code.publisher.tsandlimits.tsand failed at its bound.Alternatives
createMockTransportPairto model stream credit. A second credit implementation could drift from qmux's real behavior.Follow-ups
qmuxPairhelper could move tojs/net/src/mock.tsfor other tests that need a peer withholding credit, such as quest/m1/ietf-request-cancel.md.(Written by Claude Opus 5.5)
🤖 Generated with Claude Code