Skip to content

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

fix(storage): check warm backend before signalling sync entry

Steven Enamakelc5bc5f829ad5
diff --git a/crates/openhuman-core/src/storage/local.rs b/crates/openhuman-core/src/storage/local.rs
index 5d0d5f6322..8204526c4c 100644
--- a/crates/openhuman-core/src/storage/local.rs
+++ b/crates/openhuman-core/src/storage/local.rs
@@ -157,10 +157,11 @@ pub fn backend_for(workspace_dir: &Path) -> Result<Arc<dyn StorageBackend>> {
if let Some(backend) = installed() {
return Ok(backend);
}
+
+ let cell = workspace_backend(workspace_dir);
#[cfg(test)]
signal_test_sync_backend_entry();
- let cell = workspace_backend(workspace_dir);
let workspace_dir = workspace_dir.to_path_buf();
super::block_on_anyhow(async move { initialized_backend(cell, workspace_dir).await })
}
diff --git a/crates/openhuman-core/src/storage/local_tests.rs b/crates/openhuman-core/src/storage/local_tests.rs
index 8198faa787..6f0d6de96a 100644
--- a/crates/openhuman-core/src/storage/local_tests.rs
+++ b/crates/openhuman-core/src/storage/local_tests.rs
@@ -88,6 +88,23 @@ async fn concurrent_sync_and_async_open_share_one_workspace_backend() {
);
}
+#[tokio::test]
+async fn warm_sync_open_reuses_the_backend_without_entering_the_blocking_bridge() {
+ let dir = tempfile::tempdir().unwrap();
+ let warmed = backend_for_async(dir.path()).await.unwrap();
+ let (entered_tx, entered_rx) = std::sync::mpsc::channel();
+ super::arm_test_sync_backend_entry_signal(entered_tx);
+
+ let synchronous = backend_for(dir.path()).unwrap();
+
+ assert!(Arc::ptr_eq(&warmed, &synchronous));
+ assert_eq!(
+ entered_rx.try_recv(),
+ Err(std::sync::mpsc::TryRecvError::Empty),
+ "a warm backend lookup should not block the calling Tokio worker"
+ );
+}
+
#[test]
fn current_thread_sync_fallback_does_not_deadlock_on_async_backend_initialization() {
const CHILD: &str = "OPENHUMAN_STORAGE_LOCAL_ASYNC_INIT_CHILD";