Browse Source

fix(core): command stack overflow on Windows, closes #4548 (#4562)

Lucas Fernandes Nogueira 3 năm trước cách đây
mục cha
commit
7e3ac8475c

+ 5 - 0
.changes/fix-async-runtime-stack-overflow.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Fix stack overflow on Windows on commands by changing the implementation of the `async_runtime::spawn` method.

+ 8 - 2
core/tauri/src/async_runtime.rs

@@ -103,7 +103,10 @@ impl Runtime {
     F::Output: Send + 'static,
   {
     match self {
-      Self::Tokio(r) => JoinHandle::Tokio(r.spawn(task)),
+      Self::Tokio(r) => {
+        let _guard = r.enter();
+        JoinHandle::Tokio(tokio::spawn(task))
+      }
     }
   }
 
@@ -193,7 +196,10 @@ impl RuntimeHandle {
     F::Output: Send + 'static,
   {
     match self {
-      Self::Tokio(h) => JoinHandle::Tokio(h.spawn(task)),
+      Self::Tokio(h) => {
+        let _guard = h.enter();
+        JoinHandle::Tokio(tokio::spawn(task))
+      }
     }
   }