From 111c7bfa0c3015b55cd4c5f2d340a53aeff17aab Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Fri, 6 Feb 2026 11:12:00 +0800 Subject: [PATCH 1/2] feat(async_runtime): enable track_caller attribute for async_runtime under tracing feature --- .changes/feat-async_runtime-track.md | 5 +++++ crates/tauri/src/async_runtime.rs | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 .changes/feat-async_runtime-track.md diff --git a/.changes/feat-async_runtime-track.md b/.changes/feat-async_runtime-track.md new file mode 100644 index 000000000000..2f5c5559c89f --- /dev/null +++ b/.changes/feat-async_runtime-track.md @@ -0,0 +1,5 @@ +--- +"tauri": minor:feat +--- + +Enable track_caller attribute for async_runtime under the tracing feature to provide better location information in logs and panics. diff --git a/crates/tauri/src/async_runtime.rs b/crates/tauri/src/async_runtime.rs index 4925878ce99e..fc367f0072ff 100644 --- a/crates/tauri/src/async_runtime.rs +++ b/crates/tauri/src/async_runtime.rs @@ -42,6 +42,7 @@ impl GlobalRuntime { } } + #[cfg_attr(feature = "tracing", track_caller)] fn spawn(&self, task: F) -> JoinHandle where F: Future + Send + 'static, @@ -54,6 +55,7 @@ impl GlobalRuntime { } } + #[cfg_attr(feature = "tracing", track_caller)] pub fn spawn_blocking(&self, func: F) -> JoinHandle where F: FnOnce() -> R + Send + 'static, @@ -66,6 +68,7 @@ impl GlobalRuntime { } } + #[cfg_attr(feature = "tracing", track_caller)] fn block_on(&self, task: F) -> F::Output { if let Some(r) = &self.runtime { r.block_on(task) @@ -95,6 +98,7 @@ impl Runtime { } } + #[cfg_attr(feature = "tracing", track_caller)] /// Spawns a future onto the runtime. pub fn spawn(&self, task: F) -> JoinHandle where @@ -109,6 +113,7 @@ impl Runtime { } } + #[cfg_attr(feature = "tracing", track_caller)] /// Runs the provided function on an executor dedicated to blocking operations. pub fn spawn_blocking(&self, func: F) -> JoinHandle where @@ -120,6 +125,7 @@ impl Runtime { } } + #[cfg_attr(feature = "tracing", track_caller)] /// Runs a future to completion on runtime. pub fn block_on(&self, task: F) -> F::Output { match self { @@ -177,6 +183,7 @@ impl RuntimeHandle { h } + #[cfg_attr(feature = "tracing", track_caller)] /// Runs the provided function on an executor dedicated to blocking operations. pub fn spawn_blocking(&self, func: F) -> JoinHandle where @@ -188,6 +195,7 @@ impl RuntimeHandle { } } + #[cfg_attr(feature = "tracing", track_caller)] /// Spawns a future onto the runtime. pub fn spawn(&self, task: F) -> JoinHandle where @@ -202,6 +210,7 @@ impl RuntimeHandle { } } + #[cfg_attr(feature = "tracing", track_caller)] /// Runs a future to completion on runtime. pub fn block_on(&self, task: F) -> F::Output { match self { @@ -258,12 +267,14 @@ pub fn handle() -> RuntimeHandle { runtime.handle() } +#[cfg_attr(feature = "tracing", track_caller)] /// Runs a future to completion on runtime. pub fn block_on(task: F) -> F::Output { let runtime = RUNTIME.get_or_init(default_runtime); runtime.block_on(task) } +#[cfg_attr(feature = "tracing", track_caller)] /// Spawns a future onto the runtime. pub fn spawn(task: F) -> JoinHandle where @@ -274,6 +285,7 @@ where runtime.spawn(task) } +#[cfg_attr(feature = "tracing", track_caller)] /// Runs the provided function on an executor dedicated to blocking operations. pub fn spawn_blocking(func: F) -> JoinHandle where @@ -284,6 +296,7 @@ where runtime.spawn_blocking(func) } +#[cfg_attr(feature = "tracing", track_caller)] #[allow(dead_code)] pub(crate) fn safe_block_on(task: F) -> F::Output where From 753874524311bbc80c3cac76336934eb9b518c09 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Wed, 29 Apr 2026 19:00:09 +0800 Subject: [PATCH 2/2] fix: `track_caller` enable by default for async_runtime --- .changes/feat-async_runtime-track.md | 2 +- crates/tauri/src/async_runtime.rs | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.changes/feat-async_runtime-track.md b/.changes/feat-async_runtime-track.md index 2f5c5559c89f..7a761ccbe09d 100644 --- a/.changes/feat-async_runtime-track.md +++ b/.changes/feat-async_runtime-track.md @@ -2,4 +2,4 @@ "tauri": minor:feat --- -Enable track_caller attribute for async_runtime under the tracing feature to provide better location information in logs and panics. +Enable track_caller attribute for async_runtime to provide better location information in logs and panics. diff --git a/crates/tauri/src/async_runtime.rs b/crates/tauri/src/async_runtime.rs index fc367f0072ff..3ccc2c3bf68c 100644 --- a/crates/tauri/src/async_runtime.rs +++ b/crates/tauri/src/async_runtime.rs @@ -42,7 +42,7 @@ impl GlobalRuntime { } } - #[cfg_attr(feature = "tracing", track_caller)] + #[track_caller] fn spawn(&self, task: F) -> JoinHandle where F: Future + Send + 'static, @@ -55,7 +55,7 @@ impl GlobalRuntime { } } - #[cfg_attr(feature = "tracing", track_caller)] + #[track_caller] pub fn spawn_blocking(&self, func: F) -> JoinHandle where F: FnOnce() -> R + Send + 'static, @@ -68,7 +68,7 @@ impl GlobalRuntime { } } - #[cfg_attr(feature = "tracing", track_caller)] + #[track_caller] fn block_on(&self, task: F) -> F::Output { if let Some(r) = &self.runtime { r.block_on(task) @@ -98,7 +98,7 @@ impl Runtime { } } - #[cfg_attr(feature = "tracing", track_caller)] + #[track_caller] /// Spawns a future onto the runtime. pub fn spawn(&self, task: F) -> JoinHandle where @@ -113,7 +113,7 @@ impl Runtime { } } - #[cfg_attr(feature = "tracing", track_caller)] + #[track_caller] /// Runs the provided function on an executor dedicated to blocking operations. pub fn spawn_blocking(&self, func: F) -> JoinHandle where @@ -125,7 +125,7 @@ impl Runtime { } } - #[cfg_attr(feature = "tracing", track_caller)] + #[track_caller] /// Runs a future to completion on runtime. pub fn block_on(&self, task: F) -> F::Output { match self { @@ -183,7 +183,7 @@ impl RuntimeHandle { h } - #[cfg_attr(feature = "tracing", track_caller)] + #[track_caller] /// Runs the provided function on an executor dedicated to blocking operations. pub fn spawn_blocking(&self, func: F) -> JoinHandle where @@ -195,7 +195,7 @@ impl RuntimeHandle { } } - #[cfg_attr(feature = "tracing", track_caller)] + #[track_caller] /// Spawns a future onto the runtime. pub fn spawn(&self, task: F) -> JoinHandle where @@ -210,7 +210,7 @@ impl RuntimeHandle { } } - #[cfg_attr(feature = "tracing", track_caller)] + #[track_caller] /// Runs a future to completion on runtime. pub fn block_on(&self, task: F) -> F::Output { match self { @@ -267,14 +267,14 @@ pub fn handle() -> RuntimeHandle { runtime.handle() } -#[cfg_attr(feature = "tracing", track_caller)] +#[track_caller] /// Runs a future to completion on runtime. pub fn block_on(task: F) -> F::Output { let runtime = RUNTIME.get_or_init(default_runtime); runtime.block_on(task) } -#[cfg_attr(feature = "tracing", track_caller)] +#[track_caller] /// Spawns a future onto the runtime. pub fn spawn(task: F) -> JoinHandle where @@ -285,7 +285,7 @@ where runtime.spawn(task) } -#[cfg_attr(feature = "tracing", track_caller)] +#[track_caller] /// Runs the provided function on an executor dedicated to blocking operations. pub fn spawn_blocking(func: F) -> JoinHandle where @@ -296,7 +296,7 @@ where runtime.spawn_blocking(func) } -#[cfg_attr(feature = "tracing", track_caller)] +#[track_caller] #[allow(dead_code)] pub(crate) fn safe_block_on(task: F) -> F::Output where