Skip to content

Commit 2000d5e

Browse files
committed
core: Another attempt at making the polling_monitor_cancelation test less flaky
This change actually reveals a problem with the cancel-on-drop behavior and would need some more work to get right
1 parent afc091d commit 2000d5e

File tree

1 file changed

+6
-2
lines changed
  • core/src/polling_monitor

1 file changed

+6
-2
lines changed

core/src/polling_monitor/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,14 @@ mod tests {
368368
monitor.monitor(REQ);
369369
drop(rx);
370370
let mut next = handle.next_request().await;
371-
if let Some((a, _)) = next {
371+
if let Some((req, responder)) = next {
372372
// The request may or may not have been pulled from the queue
373373
// before cancelation.
374-
assert_eq!(REQ, a);
374+
assert_eq!(REQ, req);
375+
// Explicitly complete the request so the monitor task can process it
376+
// and detect the cancellation. Dropping the responder without responding
377+
// is racy in a multi-threaded runtime.
378+
responder.send_error(anyhow!("cancelled"));
375379
next = handle.next_request().await;
376380
}
377381
assert!(next.is_none());

0 commit comments

Comments
 (0)