Repository navigation
test(hosts): drive the stalled-resend tests by events, not sleeps - #453
Conversation
The ack test sent main's ack and resumed the paused uplink in the same tick. On a slow
runner the daemon's flush timer then resent the rest of the old lines before the ack
event was dispatched, so all of them went again ("20776 of 20776 lines resent" on
Windows). The ack now goes in the welcome's frame, applied in the same event as the
stalled flush. The helper also waits for a full unacked window instead of 300 ms and
for a message sequenced after the old lines instead of 1 s.
|
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 18 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. |
Code Review Roast 🔥Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. The test refactor swaps brittle 📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are. Files Reviewed (2 files)
Reviewed by free · Input: 37.3K · Output: 6.2K · Cached: 117.1K |
Summary
"a resend skips what main acked after the welcome" (
lib/hosts/daemon.test.mjs) failed in most recent Windows CI runs with20776 of 20776 lines resent.Cause: the test sent main's
ackand resumed the paused uplink in the same tick. Resuming drains the test socket's queue within one 5 ms tick, and the daemon's 16 ms flush timer then sends the next frames of the resend. On a slow runner both fired before theackmessage event was dispatched, so every old line went again. The daemon behaves correctly; the test raced it.Fix (events only, no timeout changes):
onHellomay return messages that go in the welcome's frame. The ack test uses it, so the daemon applies the ack in the same event as the welcome's stalled flush, before anything can resume.sleep(300)before the snapshot becomes a wait for a full unacked window (the held frames reachunackedBytes; the daemon sends nothing more after that).sleep(1_000)after resuming becomes a wait for the first message sequenced after the old lines, which the daemon sends only once the resend snapshot is consumed.sleep(100)after the redial is gone: everything after it is ordered on the socket.Testing
ack(mutation), the ack test fails with20776 of 20776 lines resent.