diff --git a/crates/durable-test/tests/it/dst_notify.rs b/crates/durable-test/tests/it/dst_notify.rs index 1d58b6f..4bea2a8 100644 --- a/crates/durable-test/tests/it/dst_notify.rs +++ b/crates/durable-test/tests/it/dst_notify.rs @@ -283,13 +283,28 @@ async fn dst_notify_timeout_records_scheduler_events(pool: sqlx::PgPool) -> anyh ); // TaskCompleted should have fired exactly once. - let complete_count = scheduler - .events() - .iter() - .filter(|e| { - matches!(e, durable_runtime::scheduler::ScheduleEvent::TaskCompleted { task_id, .. } if *task_id == task.id()) - }) - .count(); + // + // There is a small window between when the worker commits the task's + // "complete" state to the database (which causes `task.wait()` to return) + // and when it calls `scheduler.notify(TaskCompleted)`. On a multi-threaded + // runtime we may need to yield briefly to let the worker finish. + let complete_count = timeout(Duration::from_secs(5), async { + loop { + let count = scheduler + .events() + .iter() + .filter(|e| { + matches!(e, durable_runtime::scheduler::ScheduleEvent::TaskCompleted { task_id, .. } if *task_id == task.id()) + }) + .count(); + if count > 0 { + break count; + } + tokio::task::yield_now().await; + } + }) + .await + .context("TaskCompleted event not recorded within 5s")?; assert_eq!( complete_count, 1, "expected exactly 1 TaskCompleted event, got {complete_count}" diff --git a/crates/xtask/src/claude.rs b/crates/xtask/src/claude.rs index 30ef688..b2e5395 100644 --- a/crates/xtask/src/claude.rs +++ b/crates/xtask/src/claude.rs @@ -180,8 +180,7 @@ impl Setup { tracing::info!("configuring trust authentication in {hba_path}"); // Replace all auth methods with trust for local and host connections. - let new_contents = format!( - "\ + let new_contents = "\ # durable-xtask: trust auth configured # This file was modified by `cargo xtask claude setup` to allow passwordless # local development connections. @@ -189,7 +188,7 @@ local all all trust host all all 127.0.0.1/32 trust host all all ::1/128 trust " - ); + .to_string(); std::fs::write(&hba_path, new_contents) .with_context(|| format!("failed to write {hba_path}"))?;