The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(manager): add concurrent emit blocking test during teardown
Steven Enamakeld9b02e16562b
diff --git a/crates/openhuman-core/src/platform/socket/manager_tests.rs b/crates/openhuman-core/src/platform/socket/manager_tests.rsindex cb632d4a3b..3cda8d4632 100644--- a/crates/openhuman-core/src/platform/socket/manager_tests.rs+++ b/crates/openhuman-core/src/platform/socket/manager_tests.rs@@ -259,7 +259,34 @@ async fn emit_cannot_send_past_a_concurrent_teardown_drain() {release_rx.recv().expect("test task releases teardown after the pending-while-locked check");- release_tx.send(()).expect("teardown thread is waiting");+ // Teardown's clear + drain, under the held lock. `drain_pending_emits` lives+ // in the sibling `ws_loop` module; the loop replicates its try_recv sweep.+ *teardown_guard = false;+ let mut drained = 0usize;+ while rx.try_recv().is_ok() {+ drained += 1;+ }+ drop(teardown_guard);+ (drained, rx)+ });+ locked_rx.await.expect("teardown thread took the gate");++ // A concurrent emit starts while teardown holds the gate.+ let emit_mgr = Arc::clone(&mgr);+ let mut emit_task =+ tokio::spawn(async move { emit_mgr.emit("test.event", json!({ "k": "v" })).await });++ // While the gate is held, `emit` must not be able to complete: it is blocked+ // at its readiness check on the same lock teardown holds. A bare atomic flag+ // would let it read `true` and send here, past the drain below.+ assert!(+ tokio::time::timeout(Duration::from_millis(200), &mut emit_task)+ .await+ .is_err(),+ "emit must block on the readiness gate while teardown holds it"+ );++ release_tx.send(()).expect("teardown thread is waiting");let (drained, mut rx) = teardown.join().expect("teardown thread must not panic");assert_eq!(drained, 0, "nothing was queued before teardown began");