Skip to content

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

test(modules): cover the storage callback join failure

M3gA-Mind1a242fcfefa1
diff --git a/crates/openhuman-core/src/modules/storage_host.rs b/crates/openhuman-core/src/modules/storage_host.rs
index 93d0d8abb9..7e00e71021 100644
--- a/crates/openhuman-core/src/modules/storage_host.rs
+++ b/crates/openhuman-core/src/modules/storage_host.rs
@@ -702,11 +702,14 @@ pub(super) async fn prepare_module_callbacks(
runtime
.spawn(prepare_callbacks(runtime.connection(), runtime.host()))
.await
- .map_err(|error| {
- tinybus::Error::Transport(format!(
- "the module storage callbacks did not finish: {error}"
- ))
- })?
+ .map_err(callbacks_join_failed)?
+}
+
+/// The preparing task panicked or was cancelled before it returned a binding.
+fn callbacks_join_failed(error: tokio::task::JoinError) -> tinybus::Error {
+ tinybus::Error::Transport(format!(
+ "the module storage callbacks did not finish: {error}"
+ ))
}
/// Prepare a callback storage endpoint for a module host on `connection`.
diff --git a/crates/openhuman-core/src/modules/storage_host_tests.rs b/crates/openhuman-core/src/modules/storage_host_tests.rs
index 4bb6e94ab4..0bfda4afe0 100644
--- a/crates/openhuman-core/src/modules/storage_host_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_tests.rs
@@ -725,3 +725,16 @@ async fn a_key_provider_failure_at_bind_is_retried_not_cached() {
rig.env.keys_ready.store(true, Ordering::SeqCst);
set_secret(&rig).await.unwrap();
}
+
+#[tokio::test]
+async fn a_callback_task_that_does_not_finish_is_a_transport_error() {
+ let error = tokio::spawn(async { panic!("callback preparation panicked") })
+ .await
+ .expect_err("a panicking task fails to join");
+ match callbacks_join_failed(error) {
+ tinybus::Error::Transport(message) => {
+ assert!(message.starts_with("the module storage callbacks did not finish"));
+ }
+ other => panic!("expected a transport error, got {other:?}"),
+ }
+}