Skip to content

Wait for the outbox to drop the last batch before a test checks it is empty - #546

Merged
SunkenInTime merged 2 commits into
mainfrom
t3/wait-for-acknowledged-ops
Nov 11, 2026
Merged

SunkenInTime merged 2 commits into
mainfrom
t3/wait-for-acknowledged-ops

Conversation

@SunkenInTime

@SunkenInTime SunkenInTime commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

A test of the cloud save queue failed once on main (run, attempt 1) and passed on rerun. This makes the test wait for what it then checks, so main stops failing at random.

What was wrong

reconnectAndSend in test/offline_page_changes_test.dart sent until nothing was queued, then returned. A change the server has accepted stays listed until the outbox has removed it from disk, and on a slow machine that removal outlasted the helper's fixed number of turns. The test then found one change (move-3-first) still listed and failed at expect(queue().pending, isEmpty).

No change was stuck. In 92 early returns observed under load, each had one in-flight entry, nothing queued and all three server batches done, and each cleared by itself with no further send.

The change

After the send loop, the helper waits up to five seconds for in-flight changes to leave the outbox. It does not throw when they stay, so a test that expects held work still reaches its own assertions. No app code changes.

Seen running

On Linux, four copies of the file at concurrency 4, pinned to one CPU beside a busy loop:

Result
Before, the one test, 252 runs 78 failed, all at this assertion
After, the whole file, 252 runs (10,332 tests) 0 failed

Not checked: Windows under the same load.

ci: test

Summary by CodeRabbit

  • Tests
    • Added coverage for waiting for in-flight page changes to clear from the queue during reconnection.

RetriggerView in GreptileConfidence Score: 5/5

This test-only change appears safe to merge.

Summary

reconnectAndSend now waits for in-flight work after each batch, before checking whether more work is queued.

  • Offline page tests wait for in-flight changes to leave the outbox.

Reviews (2) · Last reviewed commit: "Look again for queued work after each ba..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

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 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review 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: 3b012939-11e8-4d26-b0ad-90f3919f7b0d
Commits

Reviewing files that changed from the base of the PR and between 1cf2db7 and 368b63c.

Files selected for processing: 1

  • test/offline_page_changes_test.dart
Walkthrough

The reconnect test helper now polls for in-flight page changes after its flush-and-settle loop. It stops when the queue clears or five seconds elapse, with one-millisecond waits between checks.

Changes: Offline page changes

Layer / File(s) Summary
Wait for in-flight changes
test/offline_page_changes_test.dart
After the flush loop, reconnectAndSend polls until in-flight changes leave the queue or five seconds elapse. Each wait is one millisecond.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Possibly related PRs

  • SunkenInTime/icarus#526: Adds race tests that hold durable outbox removal while an answer is stored. Both PRs address the interval between server acceptance and durable outbox removal.
Merge Risk: Minimal · previous review 1cf2d

This change makes an offline page-change test helper wait longer for in-flight changes to clear, which should reduce intermittent test failures. It has no production impact. The remaining concern about multi-batch tests is unconfirmed, so merge-readiness risk is minimal.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: waiting for the final outbox batch to be removed before asserting that the outbox is empty.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 1

test/offline_page_changes_test.dart-60-60: 1

60-60: Major · Stability & Availability · Heavy lift

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Wait across batch transitions.

When a batch completes with more work queued, inFlightByEntityKey can become empty before the next batch is claimed. The helper can then return before that work reaches the server, so multi-batch tests can still fail under load. The queue schedules the next flush without awaiting it. (raw.githubusercontent.com)

Continue draining runnable work within the deadline, while allowing held work to reach its assertions.

Review info

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: 083d458d-b3c2-47da-afab-cf8bcbce886c
Commits

Reviewing files that changed from the base of the PR and between 141c9e5 and 1cf2db7.

Files selected for processing: 1

  • test/offline_page_changes_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@greptile-apps
greptile-apps Bot dismissed their stale review November 11, 2026 17:09

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@SunkenInTime
SunkenInTime merged commit a0d34dc into main Nov 11, 2026
17 checks passed
@SunkenInTime
SunkenInTime deleted the t3/wait-for-acknowledged-ops branch November 11, 2026 17:19
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