Skip to content

fix(net): a lite-07 drop ends a stream whose reset a browser lost - #9740

Merged
kixelated merged 7 commits into
mainfrom
quest/m2/lite07-subscribe/excused-stream-drop
Nov 27, 2026
Merged

kixelated merged 7 commits into
mainfrom
quest/m2/lite07-subscribe/excused-stream-drop

Conversation

@kixelated

@kixelated kixelated commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Claims quest/m2/lite07-subscribe/excused-stream-drop.md, and finishes it (the quest file is deleted).

Problem

Chromium can lose the reset of a Group Stream it has not handed to the page yet, leaving the stream open forever. The JS lite-07 subscriber "excused" such a stream when a SUBSCRIBE_DROP named its group, and Tail.settle then gave up on it after a timer (limit ?? GRACE). That was the last timer a JS lite-07 subscription waited out. Since moq-dev/moq#9686, a lite-07 publisher names every group whose stream it resets without a RESET_STREAM_AT covering the GROUP header, so the drop always comes. The draft already settles a subscriber's tail once every Group Stream is "read/reset/dropped" (draft line 235), so a dropped group's stream need not be waited for at all.

Approach

  • Tail loses its excused streams (Counted.excuse, #excused). With no grace, settle arms no timer. Before lite-07 the grace and limit behave as before (nothing excused streams there).
  • On lite-07, a drop (other than SKIP) naming a group lets go of the hold that group's streams have on the subscription's end (Counted.done), at once and with no timer. A stream whose header the drop overtook holds no end either, even if it then takes the group from another subscription's copy that failed.
  • The drop never cuts a read itself. A final drop ends the read through the track's own abort of the arriving group, as before. A stale (OLD) drop leaves the group arriving, as the track's contract (js/net/src/track.ts #drop) and Rust's a_group_wins_over_its_stale_drop say, until the stream's own end or the track's release.
  • SubscribeEntry.reading is keyed by the stream's Counted, so two streams of one group cannot overwrite each other.

Rust needs nothing similar: its tail never excused streams, its transports always deliver a reset, and no Rust subscriber runs in a browser.

Impact

  • Public API: none (Tail and Counted are @internal and not exported from @moq/net).
  • Wire: none, and no draft change.
  • Behavior (lite-07, JS subscriber): after SUBSCRIBE_END, the subscriber FINs without waiting on any stream a drop named, instead of waiting up to GRACE. A group that a stale drop left arriving and that has not finished when the publisher's FIN releases the track is cut with Cancel. Before, it got up to GRACE to finish. Pre-lite-07 is unchanged.

Alternatives

  • Abort or stop the stream on the drop. Tried first, and dropped after review: it discards a stale-dropped group that still arrives whole when every byte landed and QUIC ignored the reset, and it breaks the track's stale-drop contract.
  • Keep a bounded drain (the old GRACE) for stale-dropped groups before releasing the track. Rejected: it is a lite-07 stall timer, which the epic's goal (quest/m2/lite07-subscribe/README.md) rules out.
  • Exempt a still-written group from the release's abort. Rejected: a group whose reset Chromium lost would then stay open forever after its track ended, holding its reader with no end.

Decisions

Taken while the maintainer was away, each with the recommended option:

  • A stale-dropped group still arriving when the publisher's FIN releases the track is cut with Cancel, rather than given a timed drain (see Alternatives). It only happens at a subscription's end, for a group the subscription's own budget already expired.
  • The two reviewers conflicted on a stream that a drop overtook and that then takes the group from another subscription's failed copy. Claude recommended holding the end for it again, Codex keeping it let go. I took Codex's: the drop already named this stream's group on the wire, so holding it brings back the unbounded wait on a reset Chromium can lose.
  • The one-shot fetch path is left as on the base. It never used the timer, and its lost-reset wait ends when its reader leaves.

Caused by

Validation

  • Reproduced first: the lost-reset subscriber tests (a stale drop before or after the header, a final drop before it, and a drop during a duplicate wait) fail on the branch base without a clock advance, since the base FINs only after GRACE. All pass here with no clock advance. "A final drop after the header" already ended on the base, through the track's abort.
  • Tests that each fail with the guarded line changed: a stale-dropped group stays open after the drop and is cut with Cancel at the release, and a stream a drop overtook holds no end after a takeover.
  • bun test in js/net: all pass. just ci (diff-selected): pass on the head. An earlier run hit the pre-existing copy_fill.test.ts:66 flake (3 of 30 reruns on the branch base too, plus 2 failures there), which moq-dev/moq#9735 owns as quest/m0/test-flakes-4/copy-fill-accept-after-close.md.
  • just test interop --all on the head: all checks passed.
  • Real browser surface, just test stream-credit --version moq-lite-07-wip (Chromium and Firefox reading through a Rust relay that resets streams to make room): fails the same way on the head and on the branch base 7297210187 with the same relay binary. Firefox leaves 157 subscriptions open (170 on base), which quest/m0/interop-green/firefox-lite07-stream-credit.md owns. Chromium's fetches of stopped groups fail with TooFarBehind: lagged on both. The nightly reports the Chromium cell passing, so this is likely local load. No regression from this change.

Follow-ups

  • None added. The Chromium stream-credit fetch failures above match the branch base and are not filed, since the nightly Chromium cell passes.
  • Not taken (review note, pre-existing on base): a stream whose reset Chromium lost after a final drop keeps its runGroup read open until the session closes. Stopping it on a final drop would be cheap, but the drop no longer cuts reads by design. Worth a look with quest/m0/interop-green/firefox-lite07-stream-credit.md.

Models

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

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: 3d85aa3

  • Base: origin/main at 83e10f0

  • Risk: medium, The change alters JS lite-07 subscriber behavior (drop handling, removal of the excused-stream grace timer, and `Counted.excuse()` removed from `tail.ts`) without changing the wire format or any frozen API, so a mistake reaches only shipped code paths through the next cut and a revert fully undoes it; what could break is a lite-07 subscription hanging or ending early for consumers if a lost reset leaves a stream open, and the only thing that would push this to high is if `Tail`/`Counted` is part of the published `@moq/net` API, which I did not verify.

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session 2739b593-8562-4a69-9e0b-25c58162d7d0

  • Risk file: bb7b1c0de60b

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

  • Session: 01a21bee-259f-7aa0-a030-27e366ff6679, round 3

  • Score: 10/10, The fix prevents a dropped stream from stalling subscription shutdown after a duplicate wait, and the incremental review found no new issues.

  • Rounds: 5; first round 2 (medium 2); findings 4 (medium 4): fixed 2, refuted 2, open 0

  • Findings: none

  • The last round's findings, at 7d9d81c:

    • Fixed: medium, js/net/src/lite/subscriber.ts:3642: Keep a dropped stream excused after a duplicate wait; js/net/src/lite/subscriber.ts:3640 releases the overtaken stream’s tail hold even after it takes over a failed copy, and js/net/src/lite/subscriber.test.ts:1901 models a copy outside that tail and checks that the subscriber sends its FIN while the overtaken stream is still open.
  • Reviewer: Claude Code, claude-opus-5-5, medium effort, second

  • Session: 3e8a5129-3b4e-4f36-9be4-e88692e05c7c

  • Rounds: 3; first round 1 (medium 1); findings 2 (medium 2): fixed 2, refuted 0, open 0

kixelated and others added 3 commits November 26, 2026 21:18
A lite-07 publisher names every group whose stream it resets without a
reliable reset in SUBSCRIBE_DROP, so the drop now stands in for the reset
a browser can lose: it ends a stream still reading the group, one waiting
on a duplicate copy, or a one-shot fetch's stream, and a stream whose
header the drop overtook is stopped unread. The excused-stream bound in
Tail.settle is gone, so no JS lite-07 subscription waits out a timer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The drop stands in for a reset a browser can lose: it ends a stream still
reading the group, one waiting on a duplicate copy, or a one-shot fetch's
stream, and a stream whose header the drop overtook is stopped unread.
Tail loses its excused streams, so its settle times nothing without a
grace. The lite-07 draft says a subscriber may stop reading on the drop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title A drop ends an excused stream's group, so JS lite-07 drops the excused-stream bound fix(net): a lite-07 drop ends a stream whose reset a browser lost Nov 27, 2026
kixelated and others added 4 commits November 26, 2026 23:12
…ords it

Aborting the group only once the read noticed the drop left it still
arriving when dropTrackGroups ran, which then skipped a stale verdict for
it. The drop now aborts the stream's group at once, as the lost reset
would have. The draft changelog notes the subscriber MAY.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A stale drop must leave its group arriving, as the track's contract and
the Rust copy do: when every byte landed, QUIC may ignore the reset and
the group still ends whole. So the drop no longer aborts or stops the
stream: it only lets go of the stream's hold on the subscription's end,
which the draft already allows (a dropped Group Stream settles the
tail). A final drop still ends the read through the track's abort. The
one-shot fetch and the draft are back as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s a failed copy

A stream that takes its group from a copy that failed while it waited
is owed again, as before, so it lets go only when it reads its own
group. The comments and test now state that the track's release cuts a
group a stale drop left arriving, rather than claiming it survives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The drop already named the stream's group on the wire, so taking the
group from another subscription's failed copy does not make the
stream's end trustworthy: its reset, which a browser can lose, may be
all that is left. The test uses another subscription's copy, as the
draft allows one stream per group per subscription.

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

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The subscriber now releases active counted reads when a drop matches their group keys. Tail no longer tracks excused reads, and settlement waits for active reads when no grace period is set. Recovery response draining uses GRACE for all versions. Tests cover drop timing, duplicate-copy waits, and settlement without grace. The proposed-change document was deleted.

Merge Risk: Minimal · up to 3d85a

This change lets a subscriber stop waiting on group streams that a drop has already accounted for, which avoids a grace-period delay when a browser loses a stream reset. No concrete defect was found in the changed behavior. Tests were reported as passing and the change is easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a lite-07 SUBSCRIBE_DROP ends a stream whose reset a browser lost. The raw summary shows the subscriber, tail, and test changes that implement this, so the title match…
Description check Passed The description explains the problem (Chromium losing Group Stream resets), the approach (removing the excused-stream timer and releasing the subscription-end hold on drop), the impact, alternatives, …
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 SUBSCRIBE_DROP ends a stream whose reset a browser lost. The raw summary shows the subscriber, tail, and test changes that implement this, so the title matches the changeset. It is specific and does not use vague terms.

Full details: Description check

Explanation

The description explains the problem (Chromium losing Group Stream resets), the approach (removing the excused-stream timer and releasing the subscription-end hold on drop), the impact, alternatives, and validation. It matches the changed files in js/net and the deleted quest file.

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: eff3ec39-48ea-4a31-8d7e-70254120e56b
Commits

Reviewing files that changed from the base of the PR and between 7297210 and 3d85aa3.

Files selected for processing: 5

  • js/net/src/lite/subscriber.test.ts
  • js/net/src/lite/subscriber.ts
  • js/net/src/tail.test.ts
  • js/net/src/tail.ts
  • quest/m2/lite07-subscribe/excused-stream-drop.md
Files with no reviewable changes: 1

  • quest/m2/lite07-subscribe/excused-stream-drop.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 27, 2026
Merged via the queue into main with commit 9c36a66 Nov 27, 2026
6 checks passed
@kixelated
kixelated deleted the quest/m2/lite07-subscribe/excused-stream-drop branch November 27, 2026 10:15
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