Skip to content

fix(net): a JS hop's data decode error never closes another session - #9829

Open
kixelated wants to merge 6 commits into
mainfrom
quest/m1/js-data-errors-stay-on-their-track
Open

kixelated wants to merge 6 commits into
mainfrom
quest/m1/js-data-errors-stay-on-their-track

Conversation

@kixelated

@kixelated kixelated commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest quest/m1/js-data-errors-stay-on-their-track.md (deleted here).

Summary

A JS node that republishes a track used to drop every broadcast on a downstream lite session because of one bad group from upstream. The lite publisher called closeViolation on every error raised while serving a track. So a decode error from another session's Group Stream (marked malformed by Reader), or a ProtocolViolation another session put on the track, closed the downstream session with "invalid control encoding" (code 3).

  • lite/publisher.ts: runSubscribe, the fetch serve, and runDatagrams no longer call closeViolation in their catch-alls, which mostly see the served track's errors. The only decodes of this session's own input inside them, the datagram and legacy-datagram update readers, now call it where they fail. SubscriptionControls already closed the session for its own update decodes. This mirrors Rust, where the publisher's malformed flag is set only from its own requester decode (rs/moq-net/src/lite/publisher.rs).
  • lite/group.ts: readFrames turns a frame decode error into StreamError(MalformedTrack). Downstream now sees 0x12 instead of an internal 0, as Rust's StreamError::from(Decode) maps it.
  • lite/error.ts: closeViolation's comment says to pass only this session's own input errors. A new servedError maps a ProtocolViolation carried by a served track or group to StreamError(MalformedTrack). The publisher's runSubscribe, fetch, and group-serve resets use it, so downstream never reads SESSION_CLOSED on a session that stays open. toStreamCode is unchanged, since Rust also maps its own violations to a session code.

Rust check: it has no such leak. Session close goes through lite::error::control at control-stream boundaries, and the publisher's malformed verdict is a local flag, not something the error value carries.

Dropped: scoping the mark in the model producers' abort. It would have caught the IETF path too, but it changes what local readers see: 19 tests deliberately check that a ProtocolViolation reaches the subscribed track's readers.

Public API / wire impact

No API change. Behavior: a downstream lite session stays open when an upstream group is malformed or an upstream session violated the protocol, and a group a JS hop cannot decode is reset downstream with MalformedTrack (0x12) instead of 0.

Caused by

  • moq-dev/moq#5550 - added closeViolation to the lite publisher's serve catch-alls, which also see errors other sessions put on the served track (found by person, through the group-id.test.ts relay chain in moq-dev/moq#9266)

Validation

  • New js/net/src/data-errors.test.ts: a lite-05 relay chain (publisher, JS forwarding hop that fails only the group it cannot read, viewer) with two broadcasts.
    • Decode case: two groups whose frame timestamps pass 2^53 ms. The hop reads each as MalformedTrack, and the second arriving proves the first left the track up. The other broadcast still delivers. Before the fix the viewer's session closed with code 3 (reproduced on the first commit).
    • Violation case: the hop's copy is aborted with a ProtocolViolation. The viewer reads MalformedTrack and the other broadcast still delivers. With servedError made a no-op this test fails, receiving code 3.
  • bun test in js/net on the first commit: 4013 pass, 0 fail. On the head, just check ran every JS package's tests, and only the next item failed.
  • just check on the head (6c8dba7): every module passes except one @moq/json test that timed out under parallel load. That test is "a live stream passes several tails and refuses a truncated replay (compress=true)", 6.8s against bun's 5s default. It uses only the local Track model (no lite session, so this change can't reach it) and passed 5 of 5 runs alone. The follow-up below tracks it.
  • Local review (codex gpt-6.2-sol xhigh, tier medium):
    • Round 1, score 6: the SUBSCRIBE reset used SESSION_CLOSED. Fixed, and its note to prove the track survives a bad group is taken.
    • Round 2, score 8: the TRACK, TRACKS, resolve-reset, SUBSCRIBE_DROP, and SUBSCRIBE_END replies did the same. Fixed with servedError at each one, and in SubscribeDrop.given.
    • Round 3, score 9: the lite-05/06 FETCH response reset did the same. Fixed per the decision above.
  • just check on 7952937: passes. A lite/fit.test.ts case timed out once in a loaded targeted run and passed 3 of 3 alone.

Decisions

  • Afk coordinator choice: ✅ fix the lite-05/06 FETCH response reset in js/net/src/lite/publisher.ts via servedError, as review round 3 recommended (rejected: accept it; drop the PR). Applied.

Follow-ups

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, unknown (arm A, cohort advisor-2026-11)

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Luke Curley and others added 2 commits November 27, 2026 22:24
A lite publisher called closeViolation on every error from the track it
served, so a decode error (marked malformed) or a violation an upstream
session put on the track closed the downstream session too. Only this
session's own decodes close it now, and a group frame this hop cannot
decode reaches downstream as MalformedTrack, mirroring Rust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title A JS hop's data decode error never closes another session fix(net): a JS hop's data decode error never closes another session Nov 28, 2026
A served track or group carrying another session's ProtocolViolation was
reset with SESSION_CLOSED although this session stays open. Map it to
MalformedTrack, and cover both the decode and the violation case with
relay-chain tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Luke Curley and others added 3 commits November 28, 2026 02:30
Neither gates the 0.22.0 cut or lite-07, and neither breaks API or wire.

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

The TRACK and TRACKS resets, the SUBSCRIBE and FETCH resolve resets,
SUBSCRIBE_DROP, and SUBSCRIBE_END's error code now read a served track's
ProtocolViolation as MalformedTrack too, rather than SESSION_CLOSED on a
session that stays open.

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

coderabbitai Bot commented Nov 28, 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 17 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

  • 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: bba7c65f-de46-46b7-8f38-eee52409d638
Commits

Reviewing files that changed from the base of the PR and between f24ac50 and a5d2b96.

Files selected for processing: 8

  • js/net/src/data-errors.test.ts
  • js/net/src/lite/error.ts
  • js/net/src/lite/group.ts
  • js/net/src/lite/publisher.ts
  • js/net/src/lite/subscribe.ts
  • quest/m1/js-data-errors-stay-on-their-track.md
  • quest/m3/js-ietf-served-violations-stay-upstream.md
  • quest/m3/json-replay-test-load-timeout.md
  • 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

This branch has not been deployed

No deployments
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