From df21ffc61f42ffb4dfde50c74a01c07a59a76e3e Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Tue, 1 Jun 2021 11:11:22 -0300 Subject: [PATCH] fix(core): command mpsc usage, closes #1935 (#1936) --- .changes/command-message-blocking.md | 5 +++++ core/tauri/src/endpoints/shell.rs | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changes/command-message-blocking.md diff --git a/.changes/command-message-blocking.md b/.changes/command-message-blocking.md new file mode 100644 index 000000000..720060d53 --- /dev/null +++ b/.changes/command-message-blocking.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +Fixes child processes messages not arriving until the subprocess is terminated. diff --git a/core/tauri/src/endpoints/shell.rs b/core/tauri/src/endpoints/shell.rs index 5ad0432ee..3f4ffdc6b 100644 --- a/core/tauri/src/endpoints/shell.rs +++ b/core/tauri/src/endpoints/shell.rs @@ -102,8 +102,9 @@ impl Cmd { let pid = child.pid(); command_childs().lock().unwrap().insert(pid, child); - crate::async_runtime::spawn(async move { - while let Some(event) = rx.recv().await { + // TODO: for some reason using `crate::async_runtime::spawn` and `rx.recv().await` doesn't work here, see issue #1935 + std::thread::spawn(move || { + while let Some(event) = rx.blocking_recv() { if matches!(event, crate::api::process::CommandEvent::Terminated(_)) { command_childs().lock().unwrap().remove(&pid); }