fix: remove catch_unwind, add error logging
All checks were successful
BotServer CI/CD / build (push) Successful in 4m22s

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-05 00:26:44 -03:00
parent b277b032b0
commit 7a5f858d86

View file

@ -287,27 +287,23 @@ pub fn send_mail_keyword(state: Arc<AppState>, user: UserSession, engine: &mut E
let user_for_task = user_fn.clone();
std::thread::spawn(move || {
let result = std::panic::catch_unwind(|| {
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build();
if let Ok(rt) = rt {
rt.block_on(async move {
let result = if let Ok(rt) = rt {
match rt.block_on(async {
execute_send_mail(&state_for_task, &user_for_task, &to_str, &subject_str, &body_str, atts, None).await
})
}) {
Ok(msg_id) => Ok(msg_id),
Err(e) => {
log::error!("execute_send_mail error: {}", e);
Err(e)
}
}
} else {
Err("Failed to build tokio runtime".to_string())
}
});
let result = match result {
Ok(r) => r,
Err(e) => {
log::error!("send_mail thread panicked: {:?}", e);
Err(format!("send_mail thread panicked: {:?}", e))
}
};
let _ = tx.send(result);