From 241ebf3dfa95cb1ea994ca87e438bd65277cd758 Mon Sep 17 00:00:00 2001 From: mubeda <1380447+mubeda@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:09:19 -0300 Subject: [PATCH] test(auth): wait for the reconcile's whole batch before draining access events The revoke-in-the-gap test read the marker link's event and then drained the channel without waiting. A reconcile sends its changes one by one under the state lock, and a receiver sees each send at once, so the drain could run before the ClientRemoved of the same batch was sent. The test then reported a resurrected client that the stream removed a moment later. Seen once on main in the Test job. With the watcher's batch slowed by a temporary probe the test failed 20 of 20 times; with the lock wait it passed 20 of 20 under the same probe and 100 of 100 without it. Co-Authored-By: Claude Fable 5.2 --- apps/server/src/auth/service.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/server/src/auth/service.rs b/apps/server/src/auth/service.rs index d15e6131b..ad060cf1f 100644 --- a/apps/server/src/auth/service.rs +++ b/apps/server/src/auth/service.rs @@ -8103,8 +8103,10 @@ mod tests { }) .await .expect("the watcher reconciled the marker"); - // One reconcile sends its pairing changes before its session changes, all under one - // lock, so the rest of the marker's batch is already queued. + // One reconcile sends its pairing changes before its session changes, all under the + // state lock. A receiver sees each send at once, so the marker can arrive while the + // rest of its batch is still unsent; taking the lock waits for the whole batch. + drop(service.state.lock().await); while let Ok(event) = events.try_recv() { fold(&event.change); }