From 2f1bbaba891ab4217b6b28b9a8df79fd752deffb Mon Sep 17 00:00:00 2001 From: Kris Hicks Date: Mon, 3 Aug 2026 16:14:26 -0700 Subject: [PATCH] test(server): close traced handler before span assertion Keep the completed instrumented handler future in an explicit pinned box and drop it after the await. This releases the handler-side request span clone before the disconnect test checks producer ownership, avoiding compiler- and platform-dependent retention of an unfinished span. Signed-off-by: Kris Hicks --- crates/openshell-server/src/grpc/sandbox.rs | 25 ++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/crates/openshell-server/src/grpc/sandbox.rs b/crates/openshell-server/src/grpc/sandbox.rs index d3cdddf41..32d8f0769 100644 --- a/crates/openshell-server/src/grpc/sandbox.rs +++ b/crates/openshell-server/src/grpc/sandbox.rs @@ -2636,16 +2636,21 @@ mod tests { let traced = test_exporter::install_traced(); let request_span = tracing::info_span!("disconnected_watch_request"); - let response = handle_watch_sandbox( - &state, - authed_request(WatchSandboxRequest { - id: sandbox.object_id().to_string(), - ..Default::default() - }), - ) - .instrument(request_span.clone()) - .await - .unwrap(); + let mut handler = Box::pin( + handle_watch_sandbox( + &state, + authed_request(WatchSandboxRequest { + id: sandbox.object_id().to_string(), + ..Default::default() + }), + ) + .instrument(request_span.clone()), + ); + let response = handler.as_mut().await.unwrap(); + // A completed instrumented future can retain its span until the future + // itself is dropped. Release the handler's clone so this test isolates + // whether the spawned watch producer retains the request span. + drop(handler); let mut stream = response.into_inner(); stream .next()