Repository navigation
fix(js/net): announce-close test counts a lite-07 removal once answered - #9177
Conversation
Quest-Claim: 5596b6ceeed4f6bb
The lite-07 case counted a removal when the peer handled the edit, but the client drops the removed prefix's claims and sends its next edit only once the peer's ANNOUNCE_OK arrives. A cycle that opened its reader in that gap was fed the stale claims, closed before any new edit went out, and the removal the test waited for never came. Count the removal once its ANNOUNCE_OK is in, and wait on the count as an event instead of a 1 s wall-clock poll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou'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 22 minutes. View limit details
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. |
|
Merge pick (maintainer away, granted the coordinator merges it confidently recommends): ✅ /quest-merge (test-only fix, standing pick), accepting the decisions listed in the PR body. (Written by Claude Opus 5.5 with high) |
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound. The race was in the test's own idea of "done", and the fix counts a lite-07 removal once the client has applied the ANNOUNCE_OK that answers it. That is the point where it drops the stale claims and can send its next edit. The fix does not just stretch the deadline.
Reviewed changes
This review covers the whole PR at a91f65c.
- Lite-07 removal counted on ANNOUNCE_OK: the
Routed.prototype.receivespy callsend(removing.shift() ?? 0)after#ok()has already run.receivehas noawaitbefore theswitch, so#ok()runs synchronously. Removals are summed per finished edit (more === false) in therequestspy and paired with OKs first-in, first-out. Lite-07 keeps only one edit unanswered at a time, so the pairing holds. - Event-driven wait:
while (ended < i) await changed.promisereplaces the 1 suntilpoll. A real hang now fails at the suite timeout, andexpect(ended).toBe(i)still catches counting too many. - Quest file removed:
quest/m0/test-flakes-3/announce-consumer-close.mdis deleted now that the quest is finished.
Spies are restored by the file-level afterEach(() => mock.restore()). The older lite drafts never reach Routed.receive, so their counting is unchanged.
claude-opus-5-5 | 𝕏

Fixes the flake in
moq-lite-07-wip: closing an announce consumer ends the peer's announce stream(js/net/src/integration.test.ts). Finishesquest/m0/test-flakes-3/announce-consumer-close.md.Cause
Load wasn't the cause. The test hangs about 1 in 800 runs on an idle host, and every failure took exactly the 1 s
untildeadline. It was a race in the test itself.The lite-07 case counted a removal when the peer handled the edit removing the prefix. The client acts on that removal only when the peer's ANNOUNCE_OK arrives: until then it keeps showing the prefix's claims, and it holds back its next edit because one is still unanswered. When the next cycle's
routes()opened in that gap, the client:next()returnedstartright away;The peer never heard of that cycle, so the removal the test waited for never came. The debug log of a failing run shows it: the third cycle's
starthas noannounced: remove= add=roomedit before it.The client behavior is correct (it sends nothing the peer doesn't need). The test's assumption was wrong.
Change
Routed.prototype.receive, paired with the edits the peer saw). The next cycle can't start until the client has dropped the stale claims, so each cycle sends its own add and remove.Validation
bun test src/integration.test.ts -t "closing an announce consumer" --rerun-each 300gave 3 failures in 2400 runs, all lite-07, each at exactly 1000 ms.--rerun-each 1000passes 8000/8000.#ask()thatRouted.attachruns when a reader closes (so the client never gives the prefix back), the lite-07 test fails (it times out at 5 s). The test still catches the leak it guards against.just checkpasses.Caused by
Decisions
untilhelper (21 other uses) as it is. Its 1 s deadline wasn't the cause here, and the other tests are out of scope.Impact
Public API: none. Wire: none. Test-only.
Follow-ups
None.
Models
Size: S
Implementer: Claude Code, claude-opus-5-5, medium effort
(Written by Claude Opus 5.5 with medium)
Review
Rewritten by
quest reviewafter each round.Head: a91f65c
Base: origin/main at 03bfeea
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:
01a1f426-dd3c-7973-a95f-2f22ed617caa, round 1Score: 9/10,
The test waits for removal acknowledgments before reopening discovery, avoiding stale claims without wall-clock polling; source review found no actionable defects, and tests were not run as instructed.Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none