From f8639f296787cfb3583d784df2b1abcca3ec09e4 Mon Sep 17 00:00:00 2001 From: spinline Date: Sat, 21 Feb 2026 00:23:23 +0300 Subject: [PATCH] chore(ui): add debug logs for SSE deserialization errors --- frontend/src/store.rs | 50 ++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/frontend/src/store.rs b/frontend/src/store.rs index 8edb028..de037d5 100644 --- a/frontend/src/store.rs +++ b/frontend/src/store.rs @@ -105,29 +105,39 @@ pub fn provide_torrent_store() { } if let Some(data_str) = msg.data().as_string() { - if let Ok(bytes) = BASE64.decode(&data_str) { - if let Ok(event) = rmp_serde::from_slice::(&bytes) { - match event { - AppEvent::FullList(list, _) => { - torrents_for_sse.update(|map| { - let new_hashes: std::collections::HashSet = list.iter().map(|t| t.hash.clone()).collect(); - map.retain(|hash, _| new_hashes.contains(hash)); - for new_torrent in list { map.insert(new_torrent.hash.clone(), new_torrent); } - }); - } - AppEvent::Update(patch) => { - if let Some(hash) = patch.hash.clone() { - torrents_for_sse.update(|map| { if let Some(t) = map.get_mut(&hash) { t.apply(patch); } }); - } - } - AppEvent::Stats(stats) => { global_stats_for_sse.set(stats); } - AppEvent::Notification(n) => { - show_toast(n.level.clone(), n.message.clone()); - if n.message.contains("tamamlandı") || n.level == shared::NotificationLevel::Error { - show_browser_notification("VibeTorrent", &n.message); + match BASE64.decode(&data_str) { + Ok(bytes) => { + match rmp_serde::from_slice::(&bytes) { + Ok(event) => { + match event { + AppEvent::FullList(list, _) => { + torrents_for_sse.update(|map| { + let new_hashes: std::collections::HashSet = list.iter().map(|t| t.hash.clone()).collect(); + map.retain(|hash, _| new_hashes.contains(hash)); + for new_torrent in list { map.insert(new_torrent.hash.clone(), new_torrent); } + }); + } + AppEvent::Update(patch) => { + if let Some(hash) = patch.hash.clone() { + torrents_for_sse.update(|map| { if let Some(t) = map.get_mut(&hash) { t.apply(patch); } }); + } + } + AppEvent::Stats(stats) => { global_stats_for_sse.set(stats); } + AppEvent::Notification(n) => { + show_toast(n.level.clone(), n.message.clone()); + if n.message.contains("tamamlandı") || n.level == shared::NotificationLevel::Error { + show_browser_notification("VibeTorrent", &n.message); + } + } } + }, + Err(e) => { + log::error!("[SSE] Failed to deserialize AppEvent: {:?}", e); } } + }, + Err(e) => { + log::error!("[SSE] Failed to decode base64: {:?}", e); } } }