From 9c639bfcc53dc6ce20c859babffa1353032554e9 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Sat, 30 May 2026 16:01:25 +0800 Subject: [PATCH] fix: run exit cleanup before app shutdown Close #7158 --- src-tauri/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index fd5167db4..55156df32 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -395,9 +395,14 @@ pub fn run() { event_handlers::handle_reopen(has_visible_windows).await; }); } - tauri::RunEvent::Exit => { + tauri::RunEvent::Exit => AsyncHandler::block_on(async { + // Windows session ending currently reaches Tao as WM_ENDSESSION and + // destroys the loop without a preventable ExitRequested event. + if !handle::Handle::global().is_exiting() { + feat::quit().await; + } logging!(info, Type::System, "Application exited"); - } + }), #[allow(unused_variables)] tauri::RunEvent::ExitRequested { api, code, .. } => { if module::lightweight::is_in_lightweight_mode() && !handle::Handle::global().is_exiting() { @@ -405,7 +410,7 @@ pub fn run() { } else if code.is_none() { api.prevent_exit(); if !handle::Handle::global().is_exiting() { - AsyncHandler::spawn(|| async { + AsyncHandler::block_on(async { feat::quit().await; }); }