Skip to content

Commit

Permalink
fix(core): command mpsc usage, closes #1935 (#1936)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Jun 1, 2021
1 parent 4bdc406 commit df21ffc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/command-message-blocking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Fixes child processes messages not arriving until the subprocess is terminated.
5 changes: 3 additions & 2 deletions core/tauri/src/endpoints/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit df21ffc

Please sign in to comment.