Skip to content

Commit 737da87

Browse files
authored
fix(core): random shell command output order, closes #2184 (#2376)
1 parent 77595b1 commit 737da87

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Fixes a consistency issue on the order of `tauri::process::Command` emitted events.

core/tauri/src/api/process/command.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::os::windows::process::CommandExt;
1919
#[cfg(windows)]
2020
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
2121

22-
use crate::async_runtime::{channel, spawn as spawn_task, Receiver};
22+
use crate::async_runtime::{block_on as block_on_task, channel, Receiver};
2323
use os_pipe::{pipe, PipeWriter};
2424
use serde::Serialize;
2525
use shared_child::SharedChild;
@@ -248,7 +248,7 @@ impl Command {
248248
let reader = BufReader::new(stdout_reader);
249249
for line in reader.lines() {
250250
let tx_ = tx_.clone();
251-
spawn_task(async move {
251+
block_on_task(async move {
252252
let _ = match line {
253253
Ok(line) => tx_.send(CommandEvent::Stdout(line)).await,
254254
Err(e) => tx_.send(CommandEvent::Error(e.to_string())).await,
@@ -264,7 +264,7 @@ impl Command {
264264
let reader = BufReader::new(stderr_reader);
265265
for line in reader.lines() {
266266
let tx_ = tx_.clone();
267-
spawn_task(async move {
267+
block_on_task(async move {
268268
let _ = match line {
269269
Ok(line) => tx_.send(CommandEvent::Stderr(line)).await,
270270
Err(e) => tx_.send(CommandEvent::Error(e.to_string())).await,
@@ -278,7 +278,7 @@ impl Command {
278278
Ok(status) => {
279279
let _l = guard.write().unwrap();
280280
commands().lock().unwrap().remove(&child_.id());
281-
spawn_task(async move {
281+
let _ = block_on_task(async move {
282282
tx.send(CommandEvent::Terminated(TerminatedPayload {
283283
code: status.code(),
284284
#[cfg(windows)]
@@ -291,7 +291,7 @@ impl Command {
291291
}
292292
Err(e) => {
293293
let _l = guard.write().unwrap();
294-
spawn_task(async move { tx.send(CommandEvent::Error(e.to_string())).await });
294+
let _ = block_on_task(async move { tx.send(CommandEvent::Error(e.to_string())).await });
295295
}
296296
};
297297
});

0 commit comments

Comments
 (0)