fix: remove last remaining block_in_place in TALK TO keyword
Some checks failed
BotServer CI/CD / build (push) Failing after 19m14s

This was the only block_in_place left causing the production panic during
bot compilation. Replaced with std:🧵:spawn + mpsc channel pattern.
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-03 18:35:27 -03:00
parent 6f183c63d2
commit 8019107ebf

View file

@ -34,13 +34,13 @@ fn register_talk_to(state: Arc<AppState>, user: UserSession, engine: &mut Engine
let state_for_send = Arc::clone(&state_clone); let state_for_send = Arc::clone(&state_clone);
let user_for_send = user.clone(); let user_for_send = user.clone();
tokio::task::block_in_place(|| { let (tx, rx) = std::sync::mpsc::channel();
std::thread::spawn(move || {
let rt = tokio::runtime::Builder::new_current_thread() let rt = tokio::runtime::Builder::new_current_thread()
.enable_all() .enable_all()
.build() .build();
.ok(); let result: Result<(), String> = match rt {
match rt { Ok(rt) => rt.block_on(async {
Some(rt) => rt.block_on(async {
send_message_to_recipient( send_message_to_recipient(
state_for_send, state_for_send,
&user_for_send, &user_for_send,
@ -48,10 +48,13 @@ fn register_talk_to(state: Arc<AppState>, user: UserSession, engine: &mut Engine
&message, &message,
) )
.await .await
.map_err(|e| format!("{}", e))
}), }),
None => Err("Failed to create runtime".into()), Err(_) => Err("Failed to create runtime".into()),
} };
}) let _ = tx.send(result);
});
rx.recv().unwrap_or(Err("Failed to receive result".into()))
.map_err(|e| format!("Failed to send message: {}", e))?; .map_err(|e| format!("Failed to send message: {}", e))?;
Ok(Dynamic::UNIT) Ok(Dynamic::UNIT)