Skip to content

fix(net): a JS group a copy's abort left buffered reads on past a later short close - #9451

Merged
kixelated merged 4 commits into
mainfrom
quest/m0/nightly/js-resume-fetched-short-close
Nov 23, 2026
Merged

kixelated merged 4 commits into
mainfrom
quest/m0/nightly/js-resume-fetched-short-close

Conversation

@kixelated

@kixelated kixelated commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/nightly/js-resume-fetched-short-close.md and deletes it.

The JS resume sweep failed at MOQ_RESUME_SEED=10 (reader 1: group 7 ended after 1 frames where a failed route closed it), which Rust passes. moq-dev/moq#9450 does not fix it: its body confirms seed 10 still fails on main at 1fd8509de7, and I reproduced that here.

Root cause

The quest's hypothesis was that nothing asks Recover.wants again after the fetched copy's short close. That turned out not to be the cause. Traced with debug prints on the shrunk case:

  1. Group 7 is still buffered for slot 0's copy subscription when slot 0 fails (down 0/0). track.ts Producer.#close then released every buffered sink group whose state had failed (hooks.releaseGroupReader(group, abort)). That release had no other effect: the group's state already held the abort. It only set the consumer's #released flag.
  2. The front's reader then takes that same consumer from the failed copy and attaches its recovery. The failure recovery ignores #released, so it fetches the rest from slot 2 and adopts it.
  3. Slot 2 closes the group short at frame 1 and fails. group.ts #continues bails on #released before ever asking Recover.wants, so the read ends at the close instead of reading on from slot 1.

Changes

  • js/net/src/track.ts: a track abort no longer releases groups still buffered for its subscribers. An unfinished one already ended with the abort, a finished one stays readable (as moq-dev/moq#9396 already made it), and a front that takes either continues it from another copy.
  • js/net/src/resume.model.test.ts: the shrunk seed-10 case joins regressions.
  • The quest file is deleted. Nothing else links to it.

Public API: none. Wire: none. Behavior: a plain subscriber is unaffected: it never gets an aborted, unfinished group handed out (an abort keeps finished groups for a slow reader, then reports it in track.test.ts), and a group's abort also ends a partial frame (group.ts cut?.done.set(outcome)), so no read waits on the missing release. Only a front, which takes groups from a failed copy, sees a difference.

Caused by

  • moq-dev/moq#9277 - added #continues, whose #released check refuses to read past a short close for a group that an earlier track abort had released before a front took it (found by check: nightly JS resume sweep, seed 10). moq-dev/moq#9396 narrowed the release to unfinished groups, which fixed only the finished-group half.

Decisions

Choices I made without asking, for review:

  • Drop the release instead of clearing #released when a front attaches its recovery. The release did nothing but set the flag, so removing it is the net simpler fix. A reset in hooks.recoverGroup would let a handle come back to life after its reader released it.
  • No separate unit test. I tried to reproduce this in resume.test.ts and track.test.ts. A plain subscriber gets error from tryRecvGroup/tryNextGroup once its track aborts. A front only takes a failed copy's buffered unfinished group through the model's received-route chain (receiveTrack, dropAnchors, Upstream, cache pool, origin routing), and rebuilding that in a unit test would duplicate the model. The regressions case is the deterministic test: it fails on main with the quest's exact error and passes here.
  • No Rust change. Rust passes seed 10, and nothing here reaches shared code.

Validation

  • Before: bun test src/resume.model.test.ts -t regressions with the new case and main's track.ts fails case 47: reader 1: group 7 ended after 1 frames where a failed route closed it. The seed-10 sweep at 4096 cases fails after 1486 cases with that error.
  • After: regressions passes, and MOQ_RESUME_SEED=10 MOQ_RESUME_CASES=4096 passes all 4096 cases.
  • Debug trace (temporary prints, since removed): consumer 974 (group 7) is released by Producer.#close at down 0/0 with no recovery attached, then gets its recovery at hand-out, adopts the fetched copy, and ends with #continues returning false on released: true.
  • Full js/net suite: 3650 pass.
  • nix develop --command just check: exit 0 (biome, JS build and tests, dead-code, quest, markdown).
  • Differential sweep, seeds 1 to 30 at 4096 cases each, on this branch and on origin/main at 1fd8509de7: this branch passes all 30. main fails seed 10 and also seed 26 (reader 0: group 2 ended after 1 frames where a failed route closed it), the same failure class, which this fix covers too.

Follow-ups

None.

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 97563d7

  • Base: origin/main at a843d23

  • Risk: medium, It changes shipped JS code in js/net/src/track.ts so a subscriber's buffered group is no longer released when a producer closes, which could alter read behavior for JS consumers of the net package, but the API and wire format stay the same and a revert fully undoes it, so it is a bug fix (medium), not a break (high).

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session 6cb42c77-02b0-4ca3-a3eb-835f5acc0a67

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

  • Session: 01a2065d-ab08-7253-96ce-76d95ca6e9d9, round 2

  • Score: 9/10, The merge preserves the previously reviewed fix and regression case with no new actionable findings, but runtime validation remains unverified because builds and tests were not run as instructed.

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

  • Findings: none

kixelated and others added 2 commits November 22, 2026 18:36
…er short close

A track abort released every failed group still buffered for a subscriber.
That release only marked the reader handle released: the group's state had
already failed. A front then took the group, attached its recovery, and
continued it from another route, but `#continues` refused to read past that
route's short close once it failed too, so the group ended early. Leave the
buffered groups to their subscribers.

Pins the JS resume sweep's seed-10 case in `regressions` and finishes
quest/m0/nightly/js-resume-fetched-short-close.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title A JS group continued by fetch keeps going past a failed route's short close fix(net): a JS group a copy's abort left buffered reads on past a later short close Nov 23, 2026
@kixelated
kixelated marked this pull request as ready for review November 23, 2026 03:10
@kixelated
kixelated enabled auto-merge November 23, 2026 03:11
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Producer.#close now closes each sink state without releasing readers for buffered groups in that loop. A regression test covers an ordered reader continuing through the next route after a fetched route closes a group short and fails. The related quest document was removed.

Merge Risk: Minimal · up to 97563

This change fixes resume behavior where a group closed short by a failed route could end the read instead of continuing from another route. No actionable merge risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a JS group that a copy's abort left buffered, so reads continued past a later short close. The changeset removes the track.ts release of buffered groups on abort and a…
Description check Passed The description explains the root cause, the changes to js/net/src/track.ts and the regression test, the deleted quest file, and validation steps. It is directly related to the changeset.
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 JS group that a copy's abort left buffered, so reads continued past a later short close. The changeset removes the track.ts release of buffered groups on abort and adds a regression case for that path, so the title matches the primary fix. It is specific and not generic.

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: dc8571d8-caac-441b-898f-79eda752d7d8
Commits

Reviewing files that changed from the base of the PR and between ee5debc and 97563d7.

Files selected for processing: 1

  • js/net/src/resume.model.test.ts

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

pullfrog[bot]
pullfrog Bot previously approved these changes Nov 23, 2026

@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. It removes the release that caused the bug rather than clearing #released again later, which would let a released handle come back to life.

Reviewed changes: I reviewed the full diff and the group.ts release and continuation paths the change relies on.

  • Producer.#close no longer releases sink-buffered groups: The removed loop only ran when the group's state already held an Error. In that case #release just set #released. #fail needs a #recover, which is attached only at hand-out. #abandon has no attempt to cancel. state.closed.set changes nothing. groupReleased waiters are added only after hand-out. Dropping the loop therefore changes only #continues: it no longer refuses to read on past a short close once a front adopts the group.
  • Partial frames stay safe without the flag: group.ts #end settles the cut frame (cut?.done.set(outcome)), so #join gets an outcome instead of waiting on the #released exit.
  • Regression case added: I checked locally that the new regressions entry fails on main's track.ts with case 47: reader 1: group 7 ended after 1 frames where a failed route closed it and passes on this branch. track.test.ts, resume.test.ts and group.test.ts also pass (547 tests).

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

@kixelated
kixelated added this pull request to the merge queue Nov 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 23, 2026
@moq-bot

moq-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

quest land watch: the merge queue removed this pull request at 9003778 because it conflicts with main (merge_conflict).

The land fixer works on it in the background, and the watcher re-enqueues it at the back of the queue once it is fixed or judged flaky, or hands it back here with what it needs.

(written by quest land watch)

@moq-bot

moq-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

quest land watch: armed auto-merge on this pull request at ee5debc, so it joins the back of the merge queue once its required checks pass, with the land fixer's fix (codex, gpt-6.1-sol, medium effort): Merged base and preserved the completed quest deletion over base’s related-link cleanup; passed nix develop --no-update-lock-file -c just ci base and git diff base --check..

(written by quest land watch)

pullfrog[bot]
pullfrog Bot previously approved these changes Nov 23, 2026

@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.

Reviewed changes: The only commit since the last review merges main. It changes nothing in js/net.

  • Kept the quest file deletion during the merge: main had edited the ## Related link in quest/m0/nightly/js-resume-fetched-short-close.md, and the merge deletes the file anyway. Nothing in the repo still links to the deleted quest. The track.ts fix and the regressions case are unchanged from the approved head 9003778.

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

# Conflicts:
#	js/net/src/resume.model.test.ts

@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.

Reviewed changes: The only commit since the last review merges main. The PR's own changes are the same as the approved version.

  • Merged main without changing the PR's own changes: main brought in #9389, which affects js/net. It adds a hooks.taking check for stale groups to the resume.ts drain walk, and Subscriber now marks a group that is stale at the bound as handed out. Neither change involves releasing groups, so the fix that removes the release from Producer.#close still applies. I ran bun test src/resume.model.test.ts -t regressions at 97563d7 and it passes.

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

@kixelated
kixelated added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit b8f6e0f Nov 23, 2026
6 checks passed
@kixelated
kixelated deleted the quest/m0/nightly/js-resume-fetched-short-close branch November 23, 2026 11:47
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