From 1c870935798ce15a524dfb5015bd0724eb557bc8 Mon Sep 17 00:00:00 2001 From: Hai Huang Date: Tue, 10 Nov 2026 07:12:52 -0500 Subject: [PATCH] fix: Wait for the emitter's row count in lines_arrive_in_order_with_token The emitter adds 1 to rows_emitted only after the write of a row returns (emitter.rs, after write_all). The mock server can get line "c" before that. The test read the count at once, so it could read 2 and fail with "left: 2, right: 3". This failed on main and on PRs. The test now polls the count until it is 3, with a 2 s limit. The assert stays, so a count that never gets to 3 still fails. To show the race, a 50 ms sleep before the bump makes the old test fail with "left: 2". The new test passes with the same sleep. Assisted-By: Claude (Anthropic AI) Signed-off-by: Hai Huang --- praxis/filters/src/record/emitter.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/praxis/filters/src/record/emitter.rs b/praxis/filters/src/record/emitter.rs index 74bbca64b..b2e0b8afe 100644 --- a/praxis/filters/src/record/emitter.rs +++ b/praxis/filters/src/record/emitter.rs @@ -382,6 +382,11 @@ mod tests { for s in ["a\n", "b\n", "c\n"] { assert_eq!(recv(&rx), s); } + // The emitter counts a row after its write returns, so the server can get "c" first. + let deadline = Instant::now() + Duration::from_secs(2); + while e.stats().rows_emitted < 3 && Instant::now() < deadline { + std::thread::sleep(Duration::from_millis(5)); + } assert_eq!(e.stats().rows_emitted, 3); }