fix(client): remove broken catch_unwind, tokio task isolation is sufficient

This commit is contained in:
Helios Agent 2026-03-03 14:43:55 +01:00
parent a43c5c3197
commit 18e844033a
No known key found for this signature in database
GPG key ID: C8259547CD8309B5

View file

@ -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) => {