We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
safe_block_on
1 parent 944b124 commit 0163489Copy full SHA for 0163489
.changes/fix-safe-block-on.md
@@ -0,0 +1,5 @@
1
+---
2
+"tauri": patch
3
4
+
5
+Fixes `Command::output` and `Command::status` deadlock when running on async commands.
core/tauri/src/async_runtime.rs
@@ -285,10 +285,11 @@ where
285
F: Future + Send + 'static,
286
F::Output: Send + 'static,
287
{
288
- if tokio::runtime::Handle::try_current().is_ok() {
+ if let Ok(handle) = tokio::runtime::Handle::try_current() {
289
let (tx, rx) = std::sync::mpsc::sync_channel(1);
290
- spawn(async move {
291
- tx.send(task.await).unwrap();
+ let handle_ = handle.clone();
+ handle.spawn_blocking(move || {
292
+ tx.send(handle_.block_on(task)).unwrap();
293
});
294
rx.recv().unwrap()
295
} else {
0 commit comments