Explorar el Código

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

Lucas Fernandes Nogueira hace 4 años
padre
commit
df21ffc61f
Se han modificado 2 ficheros con 8 adiciones y 2 borrados
  1. 5 0
      .changes/command-message-blocking.md
  2. 3 2
      core/tauri/src/endpoints/shell.rs

+ 5 - 0
.changes/command-message-blocking.md

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

+ 3 - 2
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);
               }