From 4b56b947af2856286d73b68003a203d82ffe18e7 Mon Sep 17 00:00:00 2001 From: David Lutterkort Date: Mon, 5 Jan 2026 15:29:27 -0800 Subject: [PATCH] core: Fix flakiness in polling_monitor_cancelation test --- core/src/polling_monitor/mod.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/polling_monitor/mod.rs b/core/src/polling_monitor/mod.rs index cc76c83d9ce..540403fa8c4 100644 --- a/core/src/polling_monitor/mod.rs +++ b/core/src/polling_monitor/mod.rs @@ -356,6 +356,8 @@ mod tests { #[graph::test] async fn polling_monitor_cancelation() { + const REQ: &str = "req-0"; + // Cancelation on receiver drop, no pending request. let (mut handle, _monitor, rx) = setup(); drop(rx); @@ -363,9 +365,16 @@ mod tests { // Cancelation on receiver drop, with pending request. let (mut handle, monitor, rx) = setup(); - monitor.monitor("req-0"); + monitor.monitor(REQ); drop(rx); - assert!(handle.next_request().await.is_none()); + let mut next = handle.next_request().await; + if let Some((a, _)) = next { + // The request may or may not have been pulled from the queue + // before cancelation. + assert_eq!(REQ, a); + next = handle.next_request().await; + } + assert!(next.is_none()); // Cancelation on receiver drop, while queue is waiting. let (mut handle, _monitor, rx) = setup();