From 7e3ac8475cfa146f80e13cd4e3cdf82502018d9a Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Sun, 3 Jul 2022 21:37:49 -0300 Subject: [PATCH] fix(core): command stack overflow on Windows, closes #4548 (#4562) --- .changes/fix-async-runtime-stack-overflow.md | 5 +++++ core/tauri/src/async_runtime.rs | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changes/fix-async-runtime-stack-overflow.md diff --git a/.changes/fix-async-runtime-stack-overflow.md b/.changes/fix-async-runtime-stack-overflow.md new file mode 100644 index 000000000..d5017cbfe --- /dev/null +++ b/.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. diff --git a/core/tauri/src/async_runtime.rs b/core/tauri/src/async_runtime.rs index 052193682..15937ef28 100644 --- a/core/tauri/src/async_runtime.rs +++ b/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)) + } } }