From 5d95857ea97644cca22546f476d5053fc9bf8e38 Mon Sep 17 00:00:00 2001 From: wuyangfan <1102042793@qq.com> Date: Sun, 17 May 2026 18:31:54 +0800 Subject: [PATCH] fix(revlog): avoid panic when async log fetch fails Log revlog fetch and notification errors instead of unwrapping, matching the status async fetch pattern. Fixes #2713 Co-authored-by: Cursor --- asyncgit/src/revlog.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/asyncgit/src/revlog.rs b/asyncgit/src/revlog.rs index 774d5140ef..e866b3e6e1 100644 --- a/asyncgit/src/revlog.rs +++ b/asyncgit/src/revlog.rs @@ -145,6 +145,13 @@ impl AsyncLog { Ok(false) } + /// + pub fn invalidate(&self) { + if let Ok(mut head) = self.current_head.lock() { + *head = None; + } + } + /// pub fn fetch(&self) -> Result { self.background.store(false, Ordering::Relaxed); @@ -176,18 +183,21 @@ impl AsyncLog { rayon_core::spawn(move || { scope_time!("async::revlog"); - Self::fetch_helper( + if let Err(e) = Self::fetch_helper( &repo_path, &arc_current, &arc_background, &sender, filter, - ) - .expect("failed to fetch"); + ) { + log::error!("revlog fetch_helper: {e}"); + } arc_pending.store(false, Ordering::Relaxed); - Self::notify(&sender); + if let Err(e) = sender.send(AsyncGitNotification::Log) { + log::error!("revlog notify error: {e}"); + } }); Ok(FetchStatus::Started)