Skip to content

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

fix(cron): avoid holding mutex guard across await in test gates

Steven Enamakel59de715ef7de
diff --git a/crates/openhuman-core/src/cron/documents_port.rs b/crates/openhuman-core/src/cron/documents_port.rs
index 0d8b21d643..8164a6cf85 100644
--- a/crates/openhuman-core/src/cron/documents_port.rs
+++ b/crates/openhuman-core/src/cron/documents_port.rs
@@ -362,7 +362,8 @@ async fn pause_manual_claim_if_armed(ops: &[WriteOp]) {
{
let _ = entered.send(());
}
- if let Some(release) = gate.release.lock().await.take() {
+ let release = gate.release.lock().await.take();
+ if let Some(release) = release {
let _ = release.await;
}
}
diff --git a/crates/openhuman-core/src/cron/ops_delivery_tests.rs b/crates/openhuman-core/src/cron/ops_delivery_tests.rs
index bc65f40740..fc2e3741b3 100644
--- a/crates/openhuman-core/src/cron/ops_delivery_tests.rs
+++ b/crates/openhuman-core/src/cron/ops_delivery_tests.rs
@@ -228,7 +228,7 @@ async fn manual_run_projects_its_captured_job_after_the_saved_job_is_deleted() {
&config,
&job.id,
CronJobPatch {
- name: Some(job.name.clone()),
+ name: Some("captured before delete".to_string()),
..CronJobPatch::default()
},
)
@@ -331,7 +331,7 @@ async fn detached_manual_run_waits_for_durable_admission_after_starting() {
let task_config = config.clone();
let task_job = job.clone();
let task_run_id = run_id.clone();
- let mut call = tokio::spawn(async move {
+ let call = tokio::spawn(async move {
crate::cron::scheduler::run_job_now(
&dispatch,
&task_config,
diff --git a/crates/openhuman-core/src/cron/scheduler.rs b/crates/openhuman-core/src/cron/scheduler.rs
index da4fe74ea0..7c3bff628d 100644
--- a/crates/openhuman-core/src/cron/scheduler.rs
+++ b/crates/openhuman-core/src/cron/scheduler.rs
@@ -97,6 +97,8 @@ pub async fn run(ctx: &crate::core::runtime::DispatchCtx, config: Config) -> Res
pub use dispatcher::execute_job_now;
pub(crate) use dispatcher::run_job_now;
pub(crate) use dispatcher::{tick_once, JobDispatcher};
+#[cfg(test)]
+pub(crate) use dispatcher::lose_next_ack_reply_after_commit_for_test;
pub use live_agents::run_live_agent_pass;
pub(crate) use live_agents::LiveAgentSchedulers;
pub(crate) fn scheduler_config(config: &Config) -> serde_json::Value {
diff --git a/crates/openhuman-core/src/cron/scheduler/dispatcher.rs b/crates/openhuman-core/src/cron/scheduler/dispatcher.rs
index 2bc3358084..fa3ef9eb2e 100644
--- a/crates/openhuman-core/src/cron/scheduler/dispatcher.rs
+++ b/crates/openhuman-core/src/cron/scheduler/dispatcher.rs
@@ -366,7 +366,8 @@ async fn wait_for_ack_reply_loss_test_gate(workspace: &std::path::Path) -> bool
{
let _ = entered.send(());
}
- if let Some(release) = gate.release.lock().await.take() {
+ let release = gate.release.lock().await.take();
+ if let Some(release) = release {
let _ = release.await;
}
true