Skip to content

test(hosts): drive the stalled-resend tests by events, not sleeps - #453

Merged
andrebrait merged 1 commit into
ompweb-dev:mainfrom
andrebrait:fix/resend-ack-flake
Nov 11, 2026
Merged

andrebrait merged 1 commit into
ompweb-dev:mainfrom
andrebrait:fix/resend-ack-flake

Conversation

@andrebrait

Copy link
Copy Markdown
Collaborator

Summary

"a resend skips what main acked after the welcome" (lib/hosts/daemon.test.mjs) failed in most recent Windows CI runs with 20776 of 20776 lines resent.

Cause: the test sent main's ack and 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 the ack message event was dispatched, so every old line went again. The daemon behaves correctly; the test raced it.

Fix (events only, no timeout changes):

  • The scripted server's onHello may 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 reach unackedBytes; 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

  • Both stalled-resend tests: 8 runs in a row, 2/2 pass each (Linux).
  • With the daemon ignoring the ack (mutation), the ack test fails with 20776 of 20776 lines resent.
  • Windows: this PR's CI.

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

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 930a41d3-dd83-4080-82c6-725168f47774
Commits

Reviewing files that changed from the base of the PR and between ff19996 and 08cf412.

Files selected for processing: 2

  • graphify-out/graph.json
  • lib/hosts/daemon.test.mjs
  • 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

@kilo-code-bot

kilo-code-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

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 sleep() calls for event-driven waits, moves the ack into the welcome frame so it's applied in the same event as the stalled flush, and restructures stalledRedial to take named callbacks. Every call site is updated consistently, socket is properly initialized before use, and uplink is in scope. Even the generated graph.json change is just a snapshot regen.

📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are.

Files Reviewed (2 files)
  • lib/hosts/daemon.test.mjs - 0 issues
  • graphify-out/graph.json - 0 issues (generated snapshot, skipped)

Reviewed by free · Input: 37.3K · Output: 6.2K · Cached: 117.1K

@andrebrait
andrebrait merged commit adbfd28 into ompweb-dev:main Nov 11, 2026
5 checks passed
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