From b6bcd7e6bda28c4d5798f7535e7bab499aebbc2f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 20 Feb 2026 02:32:02 +0400 Subject: [PATCH] fix: catch panics of named tasks (#22386) --- crates/tasks/src/worker_map.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/tasks/src/worker_map.rs b/crates/tasks/src/worker_map.rs index 386253d55d..60816f9328 100644 --- a/crates/tasks/src/worker_map.rs +++ b/crates/tasks/src/worker_map.rs @@ -5,7 +5,7 @@ //! named task, like a 1-thread thread pool keyed by name. use dashmap::DashMap; -use std::thread; +use std::{panic::AssertUnwindSafe, thread}; use tokio::sync::{mpsc, oneshot}; type BoxedTask = Box; @@ -26,7 +26,7 @@ impl WorkerThread { .name(name.to_string()) .spawn(move || { while let Some(task) = rx.blocking_recv() { - task(); + let _ = std::panic::catch_unwind(AssertUnwindSafe(task)); } }) .unwrap_or_else(|e| panic!("failed to spawn worker thread {name:?}: {e}"));