fix(core): command mpsc usage, closes #1935 (#1936)

This commit is contained in:
Lucas Fernandes Nogueira
2021-06-01 11:11:22 -03:00
committed by GitHub
parent 4bdc406679
commit df21ffc61f
2 changed files with 8 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"tauri": patch
---
Fixes child processes messages not arriving until the subprocess is terminated.

View File

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