Skip to content

fix(net): one namespace's stream error ends only its own advertisement - #6126

Merged
kixelated merged 3 commits into
mainfrom
quest/m0/namespace-advert-error
Oct 21, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m0/namespace-advert-error

Conversation

@kixelated

@kixelated kixelated commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Completes quest/m0/namespace-advert-error.md.

Summary

On moq-transport, a Rust publisher whose PUBLISH_NAMESPACE request stream failed before its first answer propagated the error out of run_publish_namespaces, which the session races, so one reset stream closed the whole session. A FIN before the answer went through Messages::message, which reads it as a protocol violation, so moq-tokio also stopped reconnecting.

advertise_namespace (rs/moq-net/src/ietf/publisher.rs) now separates the two kinds of failure, matching #advertise in js/net/src/ietf/publisher.ts:

  • The request's own failure (the stream reset, or ended before its answer, or a write to it failed): only that namespace is withdrawn. It comes back on the per-namespace backoff that moq-dev/moq#5998 added for idle advertisements (Watched::lapsed, 100 ms doubling to 5 s). A peer that resets every offer therefore sees backed-off re-offers, not a request loop.
  • A draft-14/15 header that fails to send: the session closes with INTERNAL_ERROR, as start_joining_fetch does, since its request ID is spent and a peer requiring the next ID would refuse every later request.
  • Session failure (the control stream when allocating a request ID or opening a stream, or a protocol violation such as a malformed answer, an unexpected message, ACTIVE_COUNT on the OK, or a second GOAWAY): this still ends the loop. A violation now closes the session at the source through Messages::failed for every case, not only ACTIVE_COUNT, so the solicited draft-14/15 path, which runs inside a request task, closes the session too.

read_response now returns the existing Answer enum (Message / Ended / Late) instead of Option. sync_namespace holds watch mutably throughout, so it no longer looks the entry up twice.

Regression test

a_failed_advertisement_ends_only_its_namespace covers draft-14 and draft-19, with both FIN and reset. Two namespaces are announced. The peer ends the first request before answering, then answers the second. The test checks that the first is offered again no sooner than RETRY_BASE, that the second is withdrawn normally when it is unannounced (PUBLISH_NAMESPACE_DONE on draft-14, a reset on draft-19), and that the loop is still running. Without the fix it fails on its first case with Session(ProtocolViolation).

a_failed_legacy_header_closes_the_session stops the request after its type and before its body: drafts 14/15 close the session, draft 19 re-offers after the backoff.

Notes

  • With ACTIVE_COUNT on a PUBLISH_NAMESPACE OK, the session close reason is now the generic protocol violation instead of the custom string. The close code is unchanged, and a_counted_publish_namespace_ok_is_a_violation still passes.
  • A failure our side causes on the request stream (an Encode error) also backs off for that namespace instead of ending the session. is_protocol_violation already treats it as not the peer's fault.

Public API / wire impact

Public API: none. Wire: none.

Checks

  • cargo nextest run --workspace --tests: 9166 passed.
  • just check: lint and fmt pass. The test stage failed twice on moq-cli export::redundant_importers_switch_through_bufferbloat_on_lite_07, a known flake on main tracked in quest/m1/test-flakes-2/redundant-failover-drift.md (moq-lite only, which this PR does not touch). It passes alone and in the full nextest run above.
  • quest check: ok.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 2 commits October 20, 2026 17:55
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A PUBLISH_NAMESPACE request stream that is reset or ended before its answer now withdraws just that namespace and re-offers it on its own growing backoff (100 ms doubling to 5 s), matching js/net. Only the control stream failing or a protocol violation, which closes the session at the source, still ends the announce loop.

Previously the error propagated out of run_publish_namespaces and closed the whole session; a FIN before the answer was read as a protocol violation, which moq-tokio treats as terminal.

Completes quest/m0/namespace-advert-error.md.

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

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T01:40:07.539188Z bf87e8a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ea24f91a-ed9c-4c22-b7b6-6383b417202a
📥 Commits

Reviewing files that changed from the base of the PR and between f915878 and bf87e8a.

📒 Files selected for processing: 3
  • quest/m0/README.md
  • quest/m0/namespace-advert-error.md
  • rs/moq-net/src/ietf/publisher.rs
  • 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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc3a26ac34

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3135 to +3137
Err(err) if !super::subscriber::is_protocol_violation(&err) => {
tracing::debug!(broadcast = %absolute, %err, "advertisement failed");
return Ok(watch.lapsed(self.runtime.now()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Close legacy sessions when request headers fail

On draft 14/15, if the peer resets the request stream before the complete PUBLISH_NAMESPACE header is written, this branch now treats the write error as a recoverable advertisement lapse. The request ID was already incremented at line 3097, but the peer may not have received it; the retry or any unrelated request therefore sends the next ID, while Control::accept requires strictly sequential IDs for these drafts and closes the session with INVALID_REQUEST_ID. The new test resets only after reading the whole request, so it misses this case. As with start_joining_fetch, an ambiguous failed legacy header must close the session rather than continue with a permanently skipped ID.

AGENTS.md reference: rs/moq-net/AGENTS.md:L6-L6

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, fixed in bf87e8a. A header that fails to send on draft 14/15 now closes the session with INTERNAL_ERROR and ends the loop, matching start_joining_fetch; later drafts still back off that namespace. a_failed_legacy_header_closes_the_session stops the stream after the type and before the body (one-message stream buffer), and fails without the fix.

(Written by Claude Opus 5.5)

Drafts 14 and 15 require the next request ID, so a header that fails to
send after its ID was allocated leaves a gap the peer refuses on every
later request. Close the session there, as the joining FETCH does.

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

Copy link
Copy Markdown
Collaborator Author

Merge summary:

  • One namespace's PUBLISH_NAMESPACE stream error (FIN or reset before its answer, or a failed write) now ends only that advertisement, which comes back on the per-namespace backoff; the control stream failing or a protocol violation still ends the loop and closes the session.
  • Codex finding fixed in bf87e8a: on drafts 14/15 a header that fails to send closes the session with INTERNAL_ERROR, since its request ID is spent and those drafts require the next ID. Regression test a_failed_legacy_header_closes_the_session, which fails without the fix.
  • Maintainer-accepted calls: the ACTIVE_COUNT close reason is now the generic protocol violation (code unchanged); a locally caused request failure backs off that namespace.
  • Public API: none. Wire: none.
  • Checks: just check passed locally on bf87e8a (7811 Rust tests plus the other suites); Codex reviewed bf87e8a with no findings.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit c305d18 Oct 21, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m0/namespace-advert-error branch October 21, 2026 04:05
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