-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Open
Labels
status: needs triageThis issue needs to triage, applied to new issuesThis issue needs to triage, applied to new issuestype: bug
Description
Describe the bug
Hello 👋
I noticed that fields in the managed state seem to be not dropped at application exit. I created a minimal example based on the template to reproduce the issue:
use tauri::{async_runtime::Mutex, Manager};
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
pub struct MyType {}
impl MyType {
pub fn new() -> MyType {
println!("Create MyType."); // Appears in the output.
MyType {}
}
}
impl Drop for MyType {
fn drop(&mut self) {
println!("Drop MyType."); // Does not appear in the output.
}
}
pub struct State {
pub my_type: MyType,
}
impl State {
pub fn new() -> State {
State {
my_type: MyType::new(),
}
}
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.setup(move |app| {
app.manage(Mutex::new(State::new()));
Ok(())
})
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}Output when ran and exited properly:
raphael@Raphaels-MBP tauri-state-drop-bug % npm run tauri dev
> [email protected] tauri
> tauri dev
Running BeforeDevCommand (`npm run dev`)
> [email protected] dev
> vite
VITE v6.4.1 ready in 100 ms
➜ Local: http://localhost:1420/
Running DevCommand (`cargo run --no-default-features --color always --`)
Info Watching /Users/raphael/Git/tauri-state-drop-bug/src-tauri for changes...
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.32s
Running `target/debug/tauri-state-drop-bug`
Create MyType.
raphael@Raphaels-MBP tauri-state-drop-bug %
Reproduction
- Clone https://github.com/raphaelmenges/tauri-state-drop-bug.
- Run
npm installin the directory. - Run
npm run tauri devin the directory.
Expected behavior
The fields in the state should be dropped at application exit.
Full tauri info output
[✔] Environment
- OS: Mac OS 15.7.1 arm64 (X64)
✔ Xcode Command Line Tools: installed
✔ Xcode: 16.4
✔ rustc: 1.88.0 (6b00bc388 2025-06-23)
✔ cargo: 1.88.0 (873a06493 2025-05-10)
✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
✔ Rust toolchain: stable-aarch64-apple-darwin (default)
- node: 22.21.0
- pnpm: 10.12.4
- npm: 11.6.2
[-] Packages
- tauri 🦀: 2.9.2
- tauri-build 🦀: 2.5.1
- wry 🦀: 0.53.5
- tao 🦀: 0.34.5
- @tauri-apps/api ⱼₛ: 2.9.0
- @tauri-apps/cli ⱼₛ: 2.9.3
[-] Plugins
- tauri-plugin-opener 🦀: 2.5.2
- @tauri-apps/plugin-opener ⱼₛ: 2.5.2
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- bundler: Vite
Stack trace
Additional context
No response
Metadata
Metadata
Assignees
Labels
status: needs triageThis issue needs to triage, applied to new issuesThis issue needs to triage, applied to new issuestype: bug