Skip to content

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

test(storage): improve bridge runtime test case

Steven Enamakelfd6ef105672a
diff --git a/crates/openhuman-core/src/storage/mod_tests.rs b/crates/openhuman-core/src/storage/mod_tests.rs
index a621f717a2..0971a0467c 100644
--- a/crates/openhuman-core/src/storage/mod_tests.rs
+++ b/crates/openhuman-core/src/storage/mod_tests.rs
@@ -181,20 +181,26 @@ async fn block_on_works_inside_a_multi_thread_runtime() {
#[tokio::test(flavor = "current_thread")]
async fn bridge_runtime_keeps_background_tasks_running_between_sync_calls() {
+ let (ready_tx, ready_rx) = tokio::sync::oneshot::channel();
let (release_tx, release_rx) = tokio::sync::oneshot::channel();
let (progress_tx, progress_rx) = std::sync::mpsc::channel();
block_on(async move {
tokio::spawn(async move {
+ let _ = ready_tx.send(());
if release_rx.await.is_ok() {
let _ = progress_tx.send(());
}
});
+ ready_rx
+ .await
+ .map_err(|error| StorageError::backend(error.to_string()))?;
Ok(())
})
.unwrap();
- // The bridge has returned to its blocking receive loop. Releasing the
- // task from the caller must still let the dedicated runtime poll it.
+ // The task was spawned on the bridge runtime and the request has returned.
+ // It must still make progress while the bridge owner waits for its next
+ // synchronous request.
release_tx.send(()).unwrap();
progress_rx
.recv_timeout(std::time::Duration::from_secs(2))