Skip to content

fix(moq-net): a lite-07 session that announced nothing closes without waiting on its route stream - #9240

Merged
kixelated merged 3 commits into
mainfrom
quest/m0/test-flakes-3/rust-audio-close-drain
Nov 21, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m0/test-flakes-3/rust-audio-close-drain

Conversation

@kixelated

@kixelated kixelated commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/test-flakes-3/rust-audio-close-drain.md.

Problem

The interop python -> rust cell once failed with Error: timeout after interop-audio had decoded the whole tone. The Rust cell always dials moq-lite-07-wip (cell_version rust is AUTH_VERSION). On lite-07 every session opens its own Announce Stream, and RouteStream held 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::close waited 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 bare Error::Timeout. The route stream's stall closes take 10 s, and a peer's close code reads as control message timeout. What it waited on: the withdrawal registration of the client's own RouteStream, in Sending::Closing, waiting for the relay to acknowledge the FIN. Owed requests (owed) were 0 throughout.

Approach

  • Answer records whether the peer was ever sent a route or a claim (announced).

  • RouteStream::poll lets go of the withdrawal once the stream owes the peer nothing:

    • it was ending without ever announcing, or
    • the session is leaving before the route layer ran (Opening or Setup), where nothing has been announced and a leaving session never starts announcing.

    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/net had the same wait: Publisher.drain awaited AnnounceStream.finish(), which waited on writer.closed once any ASK opened the stream. AnnounceStream now records whether it sent a claim (start) and waits for the FIN's acknowledgement only then. (JS lite-07 sends no routes.)

Impact

  • No public API or wire change.
  • Behavior: on lite-07, Session::close (Rust) and Connection.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

  • Reproduced on the real binaries: a relay with token auth, the Python publisher, and 24 concurrent interop-audio clients on moq-lite-07-wip under 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. On moq-lite-06 the drain was instant before the fix too, which is why the first repro (lite-06) showed nothing.
  • New 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 with moq-lite-07-wip: timeout, the error from the original cell. The existing close_times_out_waiting_for_announcement_acknowledgements still shows that a client that did announce waits for the acknowledgement (lite-07 included).
  • JS: finishing a stream that sent no claim waits on no acknowledgement finishes with FIN acknowledgements withheld and times out without the fix. finishing a stream that sent a claim waits for its acknowledgement pins that a claim still holds the close. bun test src in js/net: 3408 pass.
  • cargo nextest run -p moq-net --all-features: 4088 passed. just check and just ci pass.
  • just test interop --publishers python,rust --subscribers rust: all checks passed.
  • Under the artificial 24-client load, some clients failed with 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

  • Raising the 1 s drain deadline, or ignoring the error in the client: both rejected by the quest. The wait itself was unnecessary.
  • Dropping the hold only when the peer currently holds no claim (live/routes empty): 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

  • moq-dev/moq#8835 - gave every lite-07 session its own Announce Stream registered in the withdrawal, so a close waited on its FIN even when it announced nothing (found by check: interop on moq-dev/moq#9155).

Follow-ups

None.

Models

Size: S
Implementer: Claude, claude-opus-5-5, unknown effort (arm A)

Review

Rewritten by quest review after 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-ad4422c09319

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

  • Session: 01a1faa4-4833-7bc3-9d33-cb65d5e5a511, round 1

  • Score: 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:

    • Fixed: medium, 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.

kixelated and others added 2 commits November 20, 2026 10:25
… 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>
@kixelated kixelated changed the title The Rust audio subscriber closes within its drain fix(moq-net): a lite-07 session that announced nothing closes without waiting on its route stream Nov 20, 2026
…thout waiting on its acknowledgement

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 20, 2026 20:27

@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. 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 a Wire::Route is buffered and when a first claim is started (live.insert). I checked every Wire::Start site: the other one, in claims(), 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 for Ending/Closing when nothing was announced, and for Closed as before. It keeps holding during Open. In Opening/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 on poll_open_uni or setup. After that, the stream cannot announce: poll_send flushes, sees the withdrawal, and moves to Ending before it serves any claim.
  • JS AnnounceStream.finish: waits on writer.closed only after a start was sent. Writer.close() already swallows its rejection (js/net/src/stream.ts:835), and the lazy closed getter 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_acknowledgements still covers the case where a client did announce. The JS tests cover both branches.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

JavaScript AnnounceStream.finish() now waits for writer closure only if it sent a claim. Rust Answer records whether it sent a route or claim, and RouteStream uses that state when handling withdrawal. Tests cover these close behaviors. The Rust audio close-drain planning document was deleted.

Merge Risk: Minimal · up to c17e3

Sessions that announced nothing now close without waiting on an acknowledgement they do not need, while sessions that announced still wait. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a lite-07 session that announced nothing no longer waits on its route stream during close. It matches the changeset in routed.rs, route_stream.rs, and announce_stream.…
Description check Passed The description is closely related to the changeset. It explains the problem (lite-07 close waiting on the withdrawal tied to the Announce Stream FIN), the approach (the announced flag in Answer, the …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a lite-07 session that announced nothing no longer waits on its route stream during close. It matches the changeset in routed.rs, route_stream.rs, and announce_stream.ts. It is specific and reads clearly, though it is long for a title (97 characters).

Full details: Description check

Explanation

The description is closely related to the changeset. It explains the problem (lite-07 close waiting on the withdrawal tied to the Announce Stream FIN), the approach (the announced flag in Answer, the RouteStream::poll change, and the AnnounceStream.finish() change in js/net), the validation (new Rust and JS tests), and the impact on the public API and wire format.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

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: d3c4df9c-56c4-4e49-ae04-41eb1222916c
Commits

Reviewing files that changed from the base of the PR and between 9828a20 and c17e3e0.

Files selected for processing: 6

  • js/net/src/lite/announce_stream.test.ts
  • js/net/src/lite/announce_stream.ts
  • quest/m0/test-flakes-3/rust-audio-close-drain.md
  • rs/moq-net/src/lite/publisher/routed.rs
  • rs/moq-net/src/lite/subscriber/route_stream.rs
  • rs/moq-net/tests/integration/session_close.rs
Files with no reviewable changes: 1

  • quest/m0/test-flakes-3/rust-audio-close-drain.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

@kixelated
kixelated added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit b4664fa Nov 21, 2026
9 checks passed
@kixelated
kixelated deleted the quest/m0/test-flakes-3/rust-audio-close-drain branch November 21, 2026 01:04
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