From 18e844033ae49d13f8826bc7304d1d3a049e1f5e Mon Sep 17 00:00:00 2001 From: Helios Agent Date: Tue, 3 Mar 2026 14:43:55 +0100 Subject: [PATCH] fix(client): remove broken catch_unwind, tokio task isolation is sufficient --- crates/client/src/main.rs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/crates/client/src/main.rs b/crates/client/src/main.rs index d6ad3a4..bdc5628 100644 --- a/crates/client/src/main.rs +++ b/crates/client/src/main.rs @@ -226,26 +226,10 @@ async fn main() { let shell_clone = Arc::clone(&shell); tokio::spawn(async move { - // Catch panics so a single bad command never kills the client. - let response = std::panic::AssertUnwindSafe( - handle_message(server_msg.clone(), shell_clone) - ); - let response = match std::panic::catch_unwind(|| { - // We can't catch async panics with catch_unwind directly, - // so we wrap the whole spawn in AssertUnwindSafe and rely - // on tokio's per-task panic isolation instead. - // The real guard is that handle_message never panics — - // it uses ? / map_err everywhere. - drop(response); - }) { - Ok(()) => handle_message(server_msg, shell_clone).await, - Err(_) => { - log_err!("Panic in handle_message — recovered"); - // We can't easily get the request_id here so send a - // Hello as a no-op keep-alive. - ClientMessage::Hello { label: None } - } - }; + // tokio isolates panics per task — a panic here won't kill + // the main loop. handle_message uses map_err everywhere so + // it should never panic in practice. + let response = handle_message(server_msg, shell_clone).await; let json = match serde_json::to_string(&response) { Ok(j) => j, Err(e) => {