Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(web_chat): tolerate unrelated events in heartbeat test

Steven Enamakeld53bcc2831a1
diff --git a/crates/openhuman-core/src/web_chat/turn_host_tests.rs b/crates/openhuman-core/src/web_chat/turn_host_tests.rs
index 0edd6903cf..95c5a0da21 100644
--- a/crates/openhuman-core/src/web_chat/turn_host_tests.rs
+++ b/crates/openhuman-core/src/web_chat/turn_host_tests.rs
@@ -154,7 +154,18 @@ async fn the_heartbeat_beats_only_for_a_live_turn() {
// Before `TurnStarted` the turn is not live: no beat, however long it waits.
tokio::time::sleep(Duration::from_millis(100)).await;
- assert!(bus.try_recv().is_err());
+ loop {
+ match bus.try_recv() {
+ Ok(event) => assert_ne!(
+ event.context().thread_id,
+ "host-hb-thread",
+ "the inactive turn must not publish a heartbeat"
+ ),
+ Err(tokio::sync::broadcast::error::TryRecvError::Empty
+ | tokio::sync::broadcast::error::TryRecvError::Closed) => break,
+ Err(tokio::sync::broadcast::error::TryRecvError::Lagged(_)) => continue,
+ }
+ }
projection
.lock()