From e735a1b2e638e7ae8f80d974543826d80b4b7ee5 Mon Sep 17 00:00:00 2001 From: Deokhaeng Lee Date: Sun, 10 Aug 2025 14:16:45 -0700 Subject: [PATCH 1/2] before merge --- plugins/notification/src/worker.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/plugins/notification/src/worker.rs b/plugins/notification/src/worker.rs index 64dc902f5..f99611cb0 100644 --- a/plugins/notification/src/worker.rs +++ b/plugins/notification/src/worker.rs @@ -22,6 +22,7 @@ const EVENT_NOTIFICATION_WORKER_NAKE: &str = "event_notification_worker"; #[tracing::instrument(skip(ctx), name = EVENT_NOTIFICATION_WORKER_NAKE)] pub async fn perform_event_notification(_job: Job, ctx: Data) -> Result<(), Error> { + tracing::info!("Event notification worker executing - checking for events in next 5 minutes"); let latest_event = ctx .db .list_events(Some(ListEventFilter { @@ -38,15 +39,23 @@ pub async fn perform_event_notification(_job: Job, ctx: Data) -> Re .map_err(|e| crate::Error::Db(e).as_worker_error())?; if let Some(event) = latest_event.first() { - hypr_notification2::show(hypr_notification2::Notification { - title: "Meeting starting in 5 minutes".to_string(), - message: event.name.clone(), - url: Some(format!( - "hypr://hyprnote.com/notification?event_id={}", - event.id - )), - timeout: Some(std::time::Duration::from_secs(10)), - }); + tracing::info!("Found upcoming event - showing notification"); + + if let Err(e) = std::panic::catch_unwind(|| { + hypr_notification2::show(hypr_notification2::Notification { + title: "Meeting starting in 5 minutes".to_string(), + message: event.name.clone(), + url: Some(format!( + "hypr://hyprnote.com/notification?event_id={}", + event.id + )), + timeout: Some(std::time::Duration::from_secs(10)), + }); + }) { + tracing::error!(" Notification panic: {:?}", e); + } else { + tracing::info!(" Notification shown"); + } } Ok(()) From 0fe2d5255f033ad4496201c27da90423f9adda13 Mon Sep 17 00:00:00 2001 From: Deokhaeng Lee Date: Sun, 10 Aug 2025 14:55:51 -0700 Subject: [PATCH 2/2] coderabbit --- plugins/notification/src/worker.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/notification/src/worker.rs b/plugins/notification/src/worker.rs index f99611cb0..57c1d320a 100644 --- a/plugins/notification/src/worker.rs +++ b/plugins/notification/src/worker.rs @@ -41,7 +41,8 @@ pub async fn perform_event_notification(_job: Job, ctx: Data) -> Re if let Some(event) = latest_event.first() { tracing::info!("Found upcoming event - showing notification"); - if let Err(e) = std::panic::catch_unwind(|| { + // Wrap in AssertUnwindSafe and handle the panic properly + if let Err(e) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { hypr_notification2::show(hypr_notification2::Notification { title: "Meeting starting in 5 minutes".to_string(), message: event.name.clone(), @@ -51,10 +52,18 @@ pub async fn perform_event_notification(_job: Job, ctx: Data) -> Re )), timeout: Some(std::time::Duration::from_secs(10)), }); - }) { - tracing::error!(" Notification panic: {:?}", e); + })) { + // Convert panic payload to string for logging + let panic_msg = if let Some(s) = e.downcast_ref::<&str>() { + s.to_string() + } else if let Some(s) = e.downcast_ref::() { + s.clone() + } else { + "Unknown panic".to_string() + }; + tracing::error!("Notification panic: {}", panic_msg); } else { - tracing::info!(" Notification shown"); + tracing::info!("Notification shown"); } }