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}"));