File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
lambda-runtime/src/layers Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -204,14 +204,12 @@ mod tests {
204204 #[ tokio:: test]
205205 async fn test_non_2xx_logs_status_and_body ( ) {
206206 let storage = SharedStorage :: default ( ) ;
207- // try_init is used here intentionally: multiple tests may run concurrently and attempt
208- // to set a global subscriber. We use try_init().ok() to tolerate that gracefully.
209- // The find() below filters specifically for the 410 event so stale events from other
210- // tests don't cause false positives.
211- tracing_subscriber:: registry ( )
207+ // Use set_default (thread-local) so we don't race with other tests that call
208+ // set_global_default. #[tokio::test] uses a single-threaded executor, so the
209+ // guard remains valid for the entire test body.
210+ let _guard = tracing_subscriber:: registry ( )
212211 . with ( CaptureLayer :: new ( & storage) )
213- . try_init ( )
214- . ok ( ) ;
212+ . set_default ( ) ;
215213
216214 let server = MockServer :: start ( ) ;
217215
You can’t perform that action at this time.
0 commit comments