Repository navigation
fix(js/net): an ended reader moves its open groups off a dying route - #9410
Conversation
Quest-Claim: ec383fa00a5a8e73
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…low-up Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… reader's preferences Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. WalkthroughEnded readers now retain rerouted copies while groups already handed out still need them. They can use a replacement route to continue those groups, but do not receive new groups from copies served after track end. Readers release obsolete copies and leave the route when no outstanding group needs remain. Regression tests cover route failures, replacement routes, and short-closed groups. The change also removes a proposal document and adds a short-close investigation document. Merge Risk:
|
There was a problem hiding this comment.
ℹ️ No critical issues — two comment touch-ups only.
Approach: sound. The ended reader keeps lazily rerouted copies only for recoveries, and they never hand anything out. That matches Rust's Phase::Finished { routed } without paying anything for an ended reader that reads no group. Because Recover.#replace calls reader.sync() on every loop, a backlog group handed out after the rerouted copies were dropped still gets one on demand.
Reviewed changes
I reviewed the full diff at 3407606, including the interaction with #letGo, Route.leave, Recover.#replace, and the Rust phase it mirrors.
- Rerouted copies:
#reroutesubscribes the serving route's copy from the lowest open group whenever the route moves past the reader's copies.#unroutedrops superseded or unneeded copies and leaves the route once nothing is read or held. - Recovery lookup:
Reader.copy()andReader.holding()now also search#rerouted, and thereader.endedearly throw inRecover.#replaceis gone. - Preferences, cursor, and close:
#followandclose()now include rerouted copies. - Tests: the model oracle carve-out is removed, seeds 7 and 4 are added to
regressions, and three unit tests are ported from Rust. - Quests: the finished quest is deleted, and seed 10 is split into
js-resume-fetched-short-close.md.
ℹ️ #conclude's doc still says it leaves the route
#conclude no longer calls route.leave(this), but its JSDoc at resume.ts:1717-1720 still reads "settle closed and leave the route". That line is outside the diff hunks, so I can't comment on it inline.
Technical details
# Stale `#conclude` JSDoc
## Affected sites
- js/net/src/resume.ts:1718 — "settle `closed` and leave the route" no longer holds; `#unroute` leaves later.
## Required outcome
- The doc says the reader keeps following the route for the groups still read, and leaves it via `#unroute` once it reads and holds nothing.claude-opus-5-5 | 𝕏
|
quest land watch: ended this pull request's pick, disarming its auto-merge, since its head 3407606 is held by finding by pullfrog[bot]: This edit left line 43 at 142 characters, past biome's 120-character (written by quest land watch) |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
ℹ️ No critical issues — one earlier doc nit still stands.
Reviewed changes
I reviewed the delta since 3407606.
- Module doc reflow:
930f0fdrewraps theresume.tsmodule doc to the line width. It is comment-only and has no behavioral surface.
ℹ️ #conclude's doc still says it leaves the route
#conclude no longer leaves the route, but its JSDoc at resume.ts:1718 still reads "settle closed and leave the route". This is the same note as in the prior review. It is outside the diff hunks, so there is no inline anchor.
Technical details
# Stale `#conclude` JSDoc
## Affected sites
- js/net/src/resume.ts:1718 — "settle `closed` and leave the route" no longer holds; `#unroute` leaves later.
## Required outcome
- The doc says the reader keeps following the route for the groups still read, and leaves it via `#unroute` once it reads and holds nothing.claude-sonnet-5-5 | 𝕏
…at its end Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed Pullfrog's note in b5af62d: (Written by Claude Opus 5.5) |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
I reviewed the delta since 930f0fd.
#concludedoc: the JSDoc no longer says it leaves the route. It now says the reader follows the route only for the groups still read, and#unrouteleaves it once it reads and holds nothing. This resolves the earlier doc note. The change is comment-only.
claude-sonnet-5-5 | 𝕏

Finishes quest/m0/nightly/js-ended-reader-routed.md and deletes it.
Problem
Once a logical track ended cleanly, a JS front reader stopped following its route.
Reader.#concludeleft the route,sync()returned early once#ended, andRecover.#replacethrew on a failed group oncereader.ended. So a group still being read, whose route then died, ended where the failed copy left it. Rust's front keeps moving those groups (Phase::Finished { routed }inrs/moq-net/src/model/resume.rs), and the JS resume sweep failed on seeds 4 and 7 (7 onmaintoo).Approach
All in
js/net/src/resume.ts:Reader.out), it subscribes the new source's copy from the lowest such group. These copies (#rerouted) only back recoveries: nothing is handed out from them, so the reader stays on the copy the track ended on, as Rust's does.Reader.copy(generation)andReader.holdingalso find rerouted copies, soRecover.#replacecontinues a group there (cache, subscription, or fetch) as it does for any newer route. A rerouted copy follows the reader's preferences and cursor like any copy. Thereader.endedearly throw is gone. A concluded front still ends the group with its failure, unless a copy holds the rest.#unroutedrops a rerouted copy once a newer route supersedes it and no recovered group leases it, and drops them all once no group is read. The reader leaves the route only once nothing is read and it holds no copy, so a group it later hands out from its backlog still follows the route.js/net/src/resume.model.test.ts). Seeds 7 and 4 are added to the JSregressions.js/net/src/resume.test.ts):an ended track's group moves off a dying route, from Rust'sa_finished_tracks_fetch_moves_off_a_dying_route, for a subscribed group: it continues from the copy served next, and fails with the route's error once the front concludes.an ended track's reader hands out nothing from the copy served after the end, froma_reader_stays_on_the_copy_its_track_finished_on.an ended track's group continues from a rerouted copy's cache once the front concluded(review round 1).Decisions
My calls while the user was away. A review can undo each one:
#concludenever runs). A group continued by fetch onto slot 2 is closed short there and the route fails. JS ends the group at that close, and Rust continues it from the next route. It is a short-close judgment ingroup.ts, not routing after the end. js-resume-short-continuation waits on this PR, so I kept this diff to the ended-reader fix.Impact
Public API: none. Wire: none. Behavior (JS only): after a clean end, a group still read continues off a dying route, as in Rust, instead of failing with the route's error.
Alternatives
ResumeReader.tla'sCleanEndIsComplete).close(). This is simpler, but it keeps the route registered as long as an app holds an ended subscriber.Validation
MOQ_RESUME_SEED=1..24at 4096 cases, with this branch's oracle (carve-out removed) and withmain's:main: fails 2, 4, 7, 9, 10, 14.resume.tsand pass with it. Onmain, the group ends with the route's error at once, in both the rerouted and the concluded case.bun test src/resume src/group: 275 pass.just checkpasses on the head.Caused by
No single PR introduced a defect. A JS ended reader has followed no route since moq-dev/moq#6136, which matched Rust at the time. moq-dev/moq#8896 added routing after the end to Rust only (found by check: the JS resume sweep, on moq-dev/moq#9396).
Follow-ups
group.tsand fixing the model.Models
Size: L
Implementer: Claude Code, claude-opus-5-5, unknown effort
Implementer: Claude Code, claude-opus-5-5, unknown effort (iterate, L)
(Written by Claude Opus 5.5)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 3407606
Base: origin/main at fd59727
Risk: medium,
It changes shipped JS resume code (js/net/src/resume.ts) so an ended reader keeps following a route for groups still being read and continues a failed group from a rerouted copy, which could alter what JS consumers of moq-net receive after a route failure, but it is a bug fix that keeps the public API and wire format, so it ships as a patch and a revert fully undoes it; the test and quest-doc changes are low risk.Classified: medium by Claude Code, claude-haiku-5-5, low effort, session
cd89e6ff-260c-48cf-9f91-90ae7f8facffReviewer: Codex, gpt-6.1-sol, xhigh effort
Session:
01a203b2-4e2a-7c83-98f9-3f3784265b83, round 2Score: 10/10,
Both recovery gaps are fixed and source review found no new issues in the incremental changes; builds and tests were not run.Rounds: 2; first round 2 (medium 2); findings 2 (medium 2): fixed 2, refuted 0, open 0
Findings: none
The last round's findings, at 2bbe473:
js/net/src/resume.ts:703:Include rerouted copies in the recovery holder lookup;Reader.holding() at js/net/src/resume.ts:1203 now searches rerouted copies newest first, with the regression scenario covered by js/net/src/resume.test.ts:5323.js/net/src/resume.ts:499:Mirror preference updates into recovery-only copies;#follow() now includes rerouted copies in preference updates at js/net/src/resume.ts:985 and cursor updates at js/net/src/resume.ts:1006, keeping recovered groups synchronized with the current budget.