Skip to content

test(rpc): wait for the request to be read in race() - #108

Merged
httpsphl merged 2 commits into
mainfrom
test/rpc-queue-race
Oct 2, 2026
Merged

httpsphl merged 2 commits into
mainfrom
test/rpc-queue-race

Conversation

@httpsphl

@httpsphl httpsphl commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

race() in crates/botloftd/tests/rpc_queue.rs sent the request and had the lead bot write text right away. On the slow macOS runner (run 37015740012 on #107) the daemon parsed the bot's output before it read the request off the socket, so an_answer_goes_out_before_the_notifications_after_it got ["text", "answer"].

The test now waits 200 ms after send_raw, well under the 1 s the store is held. rpc/ has no hook that shows when a request is queued (an in-order request just blocks on the store's mutex in spawn_blocking), so a short wait is the least intrusive fix. What each test checks is unchanged: a_slow_read_holds_back_no_notification still expects the text before the files.list answer.

The wait is a std::thread::sleep, not tokio::time::sleep. With the store held, the runtime's timer did not fire until the hold ended, so a tokio sleep lasted the whole second and the text then raced the files.list answer. That made the aside test fail on Ubuntu in the first CI run. Timestamps confirmed it locally: the 200 ms sleep took about 1000 ms.

  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings: pass
  • cargo test -p botloftd --test rpc_queue: 10 runs in a row pass
  • Under load (6 copies of the test binary at once, 15 rounds): 0 of 90 runs fail. The tokio-sleep version failed 15 of 60, and main failed 0 of 60.

No real-Claude check needed: test-only change.

…ace()

On a slow runner the daemon could parse the bot's text before it took the
request off the socket, so the text legitimately went out first. Wait
200 ms after sending, well under the 1 s the store is held.
With the store held, the runtime's timer did not fire until the hold
ended, so the 200 ms tokio sleep lasted the whole second and the text
then raced the files.list answer (Rust (Ubuntu) on #108). A thread sleep
does not depend on that timer.
@httpsphl
httpsphl enabled auto-merge October 2, 2026 14:41
@httpsphl
httpsphl merged commit 0f7b214 into main Oct 2, 2026
4 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