diff --git a/crates/zed/src/reliability/hang_detection/logging.rs b/crates/zed/src/reliability/hang_detection/logging.rs index c518d03ba1..940199dec5 100644 --- a/crates/zed/src/reliability/hang_detection/logging.rs +++ b/crates/zed/src/reliability/hang_detection/logging.rs @@ -76,10 +76,9 @@ impl Reporter { task_stats: &[gpui::ThreadTaskStatistics], ) -> ReportMade { let foreground = self.foreground_thread; - let foreground = task_stats - .iter() - .find(|t| t.thread_id == foreground) - .expect("main thread should be in all statistics"); + let Some(foreground) = task_stats.iter().find(|t| t.thread_id == foreground) else { + return false; // during startup the foreground may not yet have statistics + }; let hangs: Vec<_> = foreground .stats diff --git a/crates/zed/src/reliability/hang_detection/telemetry.rs b/crates/zed/src/reliability/hang_detection/telemetry.rs index 4717cebe5a..a2d8e4136a 100644 --- a/crates/zed/src/reliability/hang_detection/telemetry.rs +++ b/crates/zed/src/reliability/hang_detection/telemetry.rs @@ -251,10 +251,10 @@ impl Reporter { fn process_foreground(&mut self, task_stats: &[gpui::ThreadTaskStatistics]) { let foreground_thread = self.foreground_thread; - let foreground = task_stats - .iter() - .find(|t| t.thread_id == foreground_thread) - .expect("main thread should be in all statistics"); + let Some(foreground) = task_stats.iter().find(|t| t.thread_id == foreground_thread) else { + // during startup foreground thread might not have statistics yet + return; + }; for hang in foreground .stats