Skip to content

fix(net): an update racing a moq-transport track's end closes no session - #9374

Merged
kixelated merged 4 commits into
mainfrom
quest/m1/ietf-update-race-session-close
Nov 22, 2026
Merged

kixelated merged 4 commits into
mainfrom
quest/m1/ietf-update-race-session-close

Conversation

@kixelated

@kixelated kixelated commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Closes the quest quest/m1/ietf-update-race-session-close.md (deleted here).

Problem

On a moq-transport session, a REQUEST_UPDATE (SUBSCRIBE_UPDATE) that crossed the end of its track closed the whole session with PROTOCOL_VIOLATION, which cost every other broadcast on it. moq-dev/moq#9265 worked around this by no longer sending the from-zero update that hit the race, so the close itself was still there.

The close came from the publisher. After a track ends, Serving sends a standalone END_OF_TRACK marker. While that marker waits for stream credit, it watched the request stream with request_stream::poll_cancel, and that treats any message as UnexpectedMessage. So an update that crossed the run's end caused Messages::failed, and that closed the session.

Approach

  • ServingStep::EndOfTrack now waits in Publisher::poll_ended_cancel. It reads the stream with poll_update, so a crossing update gets its Request ID admitted and is then dropped without an answer. The PUBLISH_DONE that follows answers it, the same way poll_retain_join already handles an update that crosses PUBLISH_DONE. The subscriber cancelling, STOP_SENDING, or the session closing still abandon the marker, as before. Its loop yields on a coop budget, as poll_discard does.
  • poll_update now closes the session itself on a protocol-violating read. Its two existing callers (RunSubscription, WaitResume) did that close the same way and otherwise treated Malformed like Failed. So UpdateRead::Malformed is merged into Failed, and the duplicated close blocks are removed.
  • JS needs no change. Its moq-transport publisher keeps a single update reader for the whole run, and that reader's errors only unsubscribe.

Impact

  • Wire: no format change. A moq-transport publisher no longer closes the session over an update that arrives while it is ending the subscription. That update now gets no REQUEST_OK, and PUBLISH_DONE follows as usual.
  • Public API: none.

Unattended choices, for review

The maintainer was away. I took my recommendation on each of these, and a review can undo any of them:

  • ✅ Drop the crossing update unanswered, rather than answering it with REQUEST_OK or REQUEST_ERROR ahead of PUBLISH_DONE. This matches the existing handling of an update that crosses PUBLISH_DONE, and an answer would describe a subscription that is already over.
  • ✅ A malformed update (a decode error, a second GOAWAY, or a bad Request ID) during the END_OF_TRACK wait still closes the session, as it does while forwarding: it is the peer's own violation, not a race.
  • ✅ Merge UpdateRead::Malformed into Failed, with the close moved into poll_update. Rejected: keeping both variants and adding a third copy of the close.

Validation

  • Reproduced on main with feat(net)!: lite-07 has no relative anchors, and Min Age places a live join #9265's shortcut disabled in wire_bounds (covered forced to false), which restores the from-zero update. Stressing the moq-ffi server_client_run_end_draft22 test binary failed in 1 of 100, 1 of 150, 5 of 200, and 2 of 200 runs. Every failure was either "the next run was never handed out" or a Session(ProtocolViolation) on the client.
  • I located the close by logging a backtrace on every code-3 session close. It always came from request_stream::Messages::failed ← poll_end ← poll_cancel ← publisher::Serving::poll (the EndOfTrack step), with the reason "unexpected message".
  • With the fix and the same reproduction patch, server_client_run_end_draft{18,20,22} passed 600 of 600 runs (200 each). The new "update crossed the end of track" path fired in 6 of 100 logged draft-22 runs, and all of them passed.
  • New test ietf::publisher::serve_tests::an_update_crossing_the_end_of_track_keeps_the_session covers drafts 18, 20, and 22. It parks the END_OF_TRACK marker without stream credit, pushes a SUBSCRIBE_UPDATE, then checks that no session close happens, that PUBLISH_DONE goes out, and that no REQUEST_OK is sent. It fails without the fix, because the request ends on the update.
  • just check passed (Rust nextest 11128 tests), just ci passed, and just test interop --all passed. After Pullfrog's finding retargeted the final-marker GOAWAY test at poll_ended_cancel (00a0047), just check passed again.

Caused by

  • moq-dev/moq#5998: made the END_OF_TRACK marker's cancellation watch read the request through Messages::poll_end, which closes the session on any message, so an update crossing the track's end closed the session (found by check: moq-ffi server_client_run_end on moq-dev/moq#9265)

Follow-ups

None.

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm B)
Implementer: Claude Code, claude-opus-5-5, unknown effort (iterate, M, arm B)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 5b54c3f

  • Base: origin/main at 1dd0968

  • Risk: medium, What could break: moq-net's IETF publisher stops closing the whole session on a malformed REQUEST_UPDATE and on an update crossing a track's end, so peers relying on those protocol-violation closes now get only the one subscription ended, a behavior change in shipped code that keeps the API and wire format; a revert restores the old behavior fully, and the deleted quest plan is documentation only, so this is a medium bug fix, not a high wire or API change.

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session a1f62202-7d06-45d6-b503-1aba6a780a96

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

  • Session: 01a20283-6811-7bd0-b1ee-a1e1095a1186, round 1

  • Score: 9/10, The fix tolerates updates crossing track completion while preserving cancellation and malformed-message handling; no actionable defects were found, though builds and tests were not run as instructed.

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

  • Findings: none

Note on the risk line: a malformed REQUEST_UPDATE still closes the session, now from poll_update for every caller. Only a well-formed update that crosses the track's end stops closing it.

Since the reviewed head, 00a0047 only retargets one test, fixing Pullfrog's single low-severity test-coverage finding, which /quest-merge exempts from a new review round.

kixelated and others added 3 commits November 22, 2026 00:03
…ssion

While the END_OF_TRACK marker waited for stream credit, the publisher read the
request stream expecting only its end, so a REQUEST_UPDATE that crossed the run's
end closed the session with PROTOCOL_VIOLATION, costing every other broadcast.
It now drops that update unanswered, as it does one crossing PUBLISH_DONE, and
poll_update closes the session on a malformed update for every caller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title An update racing a moq-transport run's end closes at most its subscription fix(net): an update racing a moq-transport track's end closes no session Nov 22, 2026
@kixelated
kixelated marked this pull request as ready for review November 22, 2026 09:10
@kixelated
kixelated enabled auto-merge November 22, 2026 09:11

@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 critical issues — one test-coverage suggestion inline.

Approach: sound — this fixes the actual source of the close (the END_OF_TRACK wait read the request stream with Messages::poll_end), and handles the crossing update the same way the path after PUBLISH_DONE already does. It is not just another workaround on the sender side.

Reviewed changes

I reviewed the full diff at 5b54c3f: the publisher's END_OF_TRACK wait, the UpdateRead consolidation, and the new regression test.

  • Publisher::poll_ended_cancel — while the marker waits for credit, an update is admitted and dropped instead of closing the session. A cancel, failure, writer close, or session close still abandons the marker.
  • UpdateRead::Malformed folded into Failed — poll_update now closes the session itself through goaways.failed(err), so the duplicate close blocks in RunSubscription and WaitResume are gone. The behavior stays the same: GOAWAY errors were already closed through Messages::receive, and other errors still close only on a protocol violation.
  • Regression test — an_update_crossing_the_end_of_track_keeps_the_session covers all drafts. It parks the marker without credit, sends an update, and checks that no close happens, that PUBLISH_DONE goes out, and that no REQUEST_OK is sent.

I also checked the other request_stream::poll_cancel callers: the joining FETCH, FetchState::Prepare/Respond, and TRACK_STATUS. None of them serve a subscription that can receive a REQUEST_UPDATE, so the same race does not reach them.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread rs/moq-net/src/ietf/publisher.rs Resolved
@moq-bot
moq-bot Bot disabled auto-merge November 22, 2026 09:13
@moq-bot

moq-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

quest land watch: ended this pull request's pick, disarming its auto-merge, since its head 5b54c3f is held by finding by pullfrog[bot]: a_subscription_keeps_its_goaway_count_until_the_final_marker (around L9756) still calls request_stream::poll_cancel (#9374 (comment)). Push a fix, or answer each by a thread reply or a comment linking its review or decision, then land it again.

(written by quest land watch)

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The publisher now routes update decode and GOAWAY-processing errors through the failed path. Decode errors pass through goaways.failed. While END_OF_TRACK waits for stream credit, the serving path calls poll_ended_cancel, which watches for cancellation or closure and discards updates. A test checks this behavior across supported versions. The related quest document was removed.

Severity of issue fixed: Low

Merge Risk: Minimal · up to 5b54c

This change stops a well-formed update that crosses the end of a track from closing the whole session, while malformed updates still close it. No actionable merge-blocking risk was identified, and the reported test coverage addresses the race.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: an update racing a moq-transport track's end no longer closes the session. It matches the objectives and the publisher.rs changes. The phrasing is slightly awkward ("c…
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.
Description check Passed The description is specific and related to the changeset. It explains the root cause (a SUBSCRIBE_UPDATE crossing a track's end closed the whole moq-transport session via request_stream::poll_cancel t…
Full details: Title check

Explanation

The title names the main change: an update racing a moq-transport track's end no longer closes the session. It matches the objectives and the publisher.rs changes. The phrasing is slightly awkward ("closes no session"), but it is specific and conveys the primary change.

Full details: Description check

Explanation

The description is specific and related to the changeset. It explains the root cause (a SUBSCRIBE_UPDATE crossing a track's end closed the whole moq-transport session via request_stream::poll_cancel treating any message as UnexpectedMessage), the approach (ServingStep::EndOfTrack now waits in Publisher::poll_ended_cancel, UpdateRead::Malformed merged into Failed, close moved into poll_update), the wire and API impact, validation steps, and the new test. This matches the raw summary of changes to rs/moq-net/src/ietf/publisher.rs and the deleted quest document.

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: 70c7bef8-9773-4a33-8d31-ec30dd8133c7
Commits

Reviewing files that changed from the base of the PR and between 0c5b90d and 5b54c3f.

Files selected for processing: 2

  • quest/m1/ietf-update-race-session-close.md
  • rs/moq-net/src/ietf/publisher.rs
Files with no reviewable changes: 1

  • quest/m1/ietf-update-race-session-close.md

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

Production's END_OF_TRACK wait now runs through Publisher::poll_ended_cancel, so
the test checking that a second GOAWAY still closes the session there drives it
instead of request_stream::poll_cancel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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. The previous test-coverage finding is addressed.

Reviewed changes

I reviewed the one commit added since the last review, 00a0047. It changes only a test.

  • Retargeted the final-marker GOAWAY test. a_subscription_keeps_its_goaway_count_until_the_final_marker now calls Publisher::poll_ended_cancel, the same wait that production's EndOfTrack step uses, and still checks for the 0x03 session close. If goaways were reset before the marker, the pushed GOAWAY would count as the first one. The poll would then stay pending and closes()[0] would be missing, so the test now catches the regression it is named for.

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

@kixelated
kixelated added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 3fb5d1b Nov 22, 2026
9 checks passed
@kixelated
kixelated deleted the quest/m1/ietf-update-race-session-close branch November 22, 2026 12:12
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