Repository navigation
fix(moq-net): a lite-07 session that announced nothing closes without waiting on its route stream - #9240
Conversation
Quest-Claim: 985374b6ad8eb408
… waiting on its route stream Every lite-07 session opens its own Announce Stream (#8835), and that stream held the close drain until the peer acknowledged its FIN. A subscriber that announced nothing has nothing for that FIN to end, yet its close waited a round trip on the peer, which under load passed the one-second drain and returned Error::Timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…thout waiting on its acknowledgement Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound. The fix targets the cause: a lite-07 route stream held the session's withdrawal until its FIN was acknowledged, even when the FIN ended nothing. It also keeps that wait for any stream that did send a route or claim, so withdrawals still land before the transport closes.
Reviewed changes
All 6 changed files across the 3 commits, in Rust and JS.
Answer::announced: set when aWire::Routeis buffered and when a first claim is started (live.insert). I checked everyWire::Startsite: the other one, inclaims(), only runs under a route that already set the flag. The flag never resets, which the PR body explains: a retracted claim's End must not race the transport close.RouteStream::owes: releases the withdrawal forEnding/Closingwhen nothing was announced, and forClosedas before. It keeps holding duringOpen. InOpening/Setup, it holds only until the withdrawal fires. Polling the withdrawal there also registers the waker, so the task wakes even while it is parked onpoll_open_unior setup. After that, the stream cannot announce:poll_sendflushes, sees the withdrawal, and moves toEndingbefore it serves any claim.- JS
AnnounceStream.finish: waits onwriter.closedonly after astartwas sent.Writer.close()already swallows its rejection (js/net/src/stream.ts:835), and the lazyclosedgetter is never touched, so skipping the wait adds no unhandled rejection. - Tests: the Rust test asserts a zero-simulated-time close across lite-01/06/07 and moq-transport-18/22 with FIN acknowledgements withheld. The existing
close_times_out_waiting_for_announcement_acknowledgementsstill covers the case where a client did announce. The JS tests cover both branches.
claude-opus-5-5 | 𝕏
|
No actionable comments were generated in the recent review. WalkthroughJavaScript Merge Risk:
|

Finishes quest/m0/test-flakes-3/rust-audio-close-drain.md.
Problem
The interop
python -> rustcell once failed withError: timeoutafterinterop-audiohad decoded the whole tone. The Rust cell always dialsmoq-lite-07-wip(cell_version rustisAUTH_VERSION). On lite-07 every session opens its own Announce Stream, andRouteStreamheld the session's withdrawal until the peer acknowledged that stream's FIN. A subscriber-only client announces nothing, so that FIN ends nothing. Even so,Session::closewaited a round trip on the relay, and under load that wait went past the one-second drain.Which deadline fired: the close drain (
Supervisor::poll_drain). Nothing else on a lite-06/07 client returns a bareError::Timeout. The route stream's stall closes take 10 s, and a peer's close code reads ascontrol message timeout. What it waited on: the withdrawal registration of the client's ownRouteStream, inSending::Closing, waiting for the relay to acknowledge the FIN. Owed requests (owed) were 0 throughout.Approach
Answerrecords whether the peer was ever sent a route or a claim (announced).RouteStream::polllets go of the withdrawal once the stream owes the peer nothing:A stream that did announce still holds the close until its FIN is acknowledged, so withdrawals still arrive before the transport closes. The stream still FINs either way. Only the drain stops waiting on it.
js/nethad the same wait:Publisher.drainawaitedAnnounceStream.finish(), which waited onwriter.closedonce any ASK opened the stream.AnnounceStreamnow records whether it sent a claim (start) and waits for the FIN's acknowledgement only then. (JS lite-07 sends no routes.)Impact
Session::close(Rust) andConnection.close(JS) for a session that announced nothing no longer waits on the peer's acknowledgement of its Announce Stream FIN. Lite-06 and earlier already behaved this way: their announce serve finishes early on an empty origin.Validation
interop-audioclients onmoq-lite-07-wipunder 12 busy loops. I added temporary timestamped logging to the drain (not committed). The drain waited on the route stream's withdrawal, for up to 629 ms (one close took 773 ms in total), while owed requests stayed 0. With the fix, the drain finished in the same poll, and the slowest close in the same setup was 281 ms. That remaining time is the transport reporting its own local close, and no deadline covers it. Onmoq-lite-06the drain was instant before the fix too, which is why the first repro (lite-06) showed nothing.session_close::close_without_announcements_waits_on_no_acknowledgement: a subscriber-only client closes with FIN acknowledgements withheld, on lite-01/06/07 and moq-transport-18/22, in zero simulated time. Without the fix it fails withmoq-lite-07-wip: timeout, the error from the original cell. The existingclose_times_out_waiting_for_announcement_acknowledgementsstill shows that a client that did announce waits for the acknowledgement (lite-07 included).finishing a stream that sent no claim waits on no acknowledgementfinishes with FIN acknowledgements withheld and times out without the fix.finishing a stream that sent a claim waits for its acknowledgementpins that a claim still holds the close.bun test srcinjs/net: 3408 pass.cargo nextest run -p moq-net --all-features: 4088 passed.just checkandjust cipass.just test interop --publishers python,rust --subscribers rust: all checks passed.audio gap(the Python publisher starved). That is a different failure from this quest's, and the matrix's normal load did not show it.Alternatives
live/routesempty): rejected. A claim retracted just before the close would then race its End against the transport close, and the peer would read the claim as lost rather than ended.Caused by
Follow-ups
None.
Models
Size: S
Implementer: Claude, claude-opus-5-5, unknown effort (arm A)
Review
Rewritten by
quest reviewafter each round.Head: c17e3e0
Base: origin/main at 847fe82
Risk: medium,
The change alters session-close acknowledgement waits in Rust and JS, which could cause premature closure or hangs for applications using moq-net; it preserves public APIs and wire formats, and a revert fully undoes it.Classified: medium by Codex, gpt-6.1-sol, low effort, session
01a1faa4-322b-7be1-be77-ad4422c09319Reviewer: Codex, gpt-6.1-sol, medium effort
Session:
01a1faa4-4833-7bc3-9d33-cb65d5e5a511, round 1Score: 9/10,
The parity gap is resolved with focused regression coverage; source review found no new actionable defects, but tests were not run as instructed.Rounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0
Findings: none
The last round's findings, at 527b7dd:
rs/moq-net/src/lite/subscriber/route_stream.rs:174:Apply the no-announcements drain fix to JS too;js/net/src/lite/announce_stream.ts:63,85 records sent claims and waits for acknowledgement only when one was sent, with added tests covering both cases.