Repository navigation
fix(net): a closed endpoint's sessions end as closed, never unroutable - #8900
Conversation
Quest-Claim: fe48449e08fd4781
…t when its closing source has no replacement A front treated an undelivered copy's end from a closing source as no verdict and kept nothing, so when nothing replaced the source the track ended Unroutable. Whether the driver saw the source closing when it read the copy's end decided the outcome, so a socket endpoint's close reached its peer as unroutable about 1 run in 6. Keep the reset as the track's loss, as a copy lost mid-serve already is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The driver reports a copy reset before its metadata was read as the query's answer, not the copy's end, so the same race reached refuse's closing branch. Keep every closing source's answer as the track's loss there, unless an earlier loss stands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the closing-source fix in Front::refuse, its regression test, and the quest cleanup.
- Closing source's answer kept as the loss:
refusenow doestrack.lost.get_or_insert(refusal.0)before its early return. This means a front ending with no replacement (origin.rs:5223readsfront.lost()) or a replacement that refuses (refusetakeslostintorefusal) reports the reset rather thanUnroutableor the replacement's error. The source is still not marked refused, and a replacement is still queried fresh. - Both delivery orderings covered: the reset reaches
refusethroughtrack_ended(undeliveredErr) and throughtrack_info(Errbefore metadata). The newa_closing_source_reset_reports_the_losstest drives both orderings, each with no replacement and with a replacement that refuses. - Stale
lostis still bounded: a successful splice clears it (track_infoOk atfront.rs:545), parking an Idle or Querying track clears it (front.rs:790), and a later mid-serve loss overwrites it. Keeping it in the closing branch therefore does not outlive the track's next real answer. - Quest cleanup: removes
quest/m0/test-flakes-3/py-socket-abort.mdand its link inquest/m2/sockets/remove.md.
One trade-off is documented in the PR's Decisions and Impact and needs no action. If a replacement refuses, it is reported with the closing source's error, and its own refusal and Retry Interval are dropped. This matches what #8373 already does for the mid-serve case.
claude-opus-5-5 | 𝕏
|
No actionable comments were generated in the recent review. WalkthroughThe front model now retains a closing-source refusal as track loss when no earlier loss exists, without recording the source as having refused the track. Tests cover reset errors received through Merge Risk:
|
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit 8646071c379d6e8842a381bce266e445e151aca7.
No actionable defect found in this static review. I traced both the undelivered TrackEnded error and pre-metadata TrackInfo(Err) through Front::refuse, then checked the driver's Action::End handling. Retaining the first loss in the closing-source branch preserves the reset without marking that source refused or preventing a replacement query. A refusing replacement uses the retained loss; a successful splice clears it, and parking an idle/querying track abandons it. The change reuses the existing recovery/error-provenance mechanism rather than adding endpoint-specific timing logic.
The new deterministic state-machine test covers both entry paths, each with no replacement and with a replacement that refuses. It checks the stored loss in the no-replacement case; the driver separately uses that loss when ending the track.
Limits: GitHub source/diff inspection only. I did not run the Rust/Python suites, repeated-process flake reproduction, interop, or the failover model, and have not independently reproduced the reported passing runs. This is a COMMENT, not an approval.

Problem
py/moq-rs/tests/test_socket.py::test_abort_and_endpoint_close_are_errorsstill failed onmainabout 1 run in 6 (10 of 60 alone): aftera.close(), the peer's read raisedProtocol: unroutableinstead ofClosed. moq-dev/moq#8825 did not fix it.The cause is in the origin's front (
rs/moq-net/src/model/front.rs), not the socket endpoint. Closing an endpoint resets its session tracks withStream(Session(Cancel))and then closes its broadcasts. The front's driver reads the copy's end and, separately, whether its source is closing (is_closing()). When the driver read the end after the close had begun, it took the undelivered copy's end as a closing source's answer, "not a verdict", kept nothing, and the front then ended with no replacement route, so the track endedUnroutable. When it read the end first, the track ended with the reset. The cross-thread timing of that one read decided the error. Any local publisher that aborts a track before writing to it and then closes its broadcast could hit this, not only sockets.Approach
Front::refusenow keeps a closing source's answer as the track'slosterror, unless an earlier loss is already recorded. It is still not a refusal: no source is marked refused, and a replacement is asked fresh. But if the front ends first, or the replacement refuses, the track ends with that answer, not withUnroutableor the refusal. That is what moq-dev/moq#8373 already does for a copy that dies mid-serve.The reset reaches the front in one of two ways. If the copy was spliced in, it arrives as the copy's end (
TrackEnded). If the copy was reset before its metadata was read, the driver reports it as the query's answer (TrackInfo(Err)). Both go throughrefuse's closing branch, so both are covered.The regression test
a_closing_source_reset_reports_the_lossdrives the state machine through both orderings, with no timing involved. It checks each against a front ending with no replacement and against a replacement that refuses. Without the fix it fails, reporting the replacement'sNotFound.This deletes the quest and its link in
quest/m2/sockets/remove.md.Decisions
/quest/m2/sockets/remove.md, which would leave the front's ordering bug in place for every local publisher.Impact
Unroutableor the replacement's refusal.Alternatives
closingwhen the copy ends, not when the driver gets to it. A copy's end and its source's close are separate channels, so this needs a snapshot across both. That costs more and still gives no ordering for a peer across a session.Validation
.tmp/loop.shran the test alone, each time in a fresh process, on a--features testing,openh264build. On the base: 3/30 and 7/30 failed, every failureMoqError.Protocol: unroutable. After each fix commit: 0/100.get_or_insertline removed (it reportsNotFoundinstead of the reset) and passes with it.cargo test -p moq-net --all-features: all pass. The full Python suite (moq-rs/tests,moq-ffi/tests): 128 passed.just check: pass on the head.just ci: pass on the first commit.just test interop --allwas not run: nothing changed in wire, moq-ffi, or gateways.verify-failover's spec models neither closing sources nor undelivered refusals, so it was not rerun.Caused by
Unroutable(found by check).Follow-ups
None.
Models
Size: S
Implementer: Claude Code, claude-opus-5-5, medium effort (arm A)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 8646071
Base: origin/main at 8f8eec3
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, medium effort
Session:
01a1e40f-ef84-7322-b9dd-a8dccd4d12c9, round 2Score: 10/10,
The head preserves the reset through both event orderings, with focused regression coverage and no new issues found by code inspection.Rounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0
Findings: none
The last round's findings, at 466f735:
rs/moq-net/src/model/front.rs:631:Preserve the reset when the copy dies before metadata is processed;The closing branch of refuse now preserves the error in track.lost, and a_closing_source_reset_reports_the_loss covers both TrackEnded and TrackInfo(Err) with no replacement and a refusing replacement.