Skip to content

fix(shell, store): do the exit work in on_cleanup_before_exit - #3749

Open
963s wants to merge 2 commits into
tauri-apps:v3from
963s:fix/shell-store-cleanup-hook
Open

963s wants to merge 2 commits into
tauri-apps:v3from
963s:fix/shell-store-cleanup-hook

Conversation

@963s

@963s 963s commented Oct 29, 2026 •

Copy link
Copy Markdown

v3 core has on_cleanup_before_exit now and its docs name this exact use
it also runs on exit paths that skip RunEvent::Exit, like AppHandle::restart on the main thread
shell and store still do their exit work on RunEvent::Exit, so on such a restart shell children keep running and unsaved store values are lost

fix
move both loops into on_cleanup_before_exit, on a normal exit it runs right after RunEvent::Exit and before the resource table is cleared
the store loop collects paths and rids first so it doesn't hold the stores lock while locking the table (the order #3746 fixes on v2)

tested on an app on tauri 3.0.0-alpha.5 + shell/store 3.0.0-alpha.3 from crates.io vs this branch
a sync command calls app.restart() after the page spawned sleep 317 and setup put {"k":42} into a store with auto save off
before: restart leaves the child running and never writes the store (2 of 2), normal exit is fine
after: child killed and store saved on both paths
tests/cleanup_close_race.rs runs cleanup_before_exit while another thread closes and reloads a store, with the loop just moved it hung 3 of 3, now ~0.6s
clippy fmt and the shell and store tests pass, macos only

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Package Changes Through dcb4824

There are 4 changes which include shell with prerelease, shell-js with prerelease, store with prerelease, store-js with prerelease

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
api-example 3.0.0-alpha.4 3.0.0-alpha.5
api-example-js 2.0.44-alpha.4 2.0.44-alpha.5
shell 3.0.0-alpha.3 3.0.0-alpha.4
shell-js 3.0.0-alpha.3 3.0.0-alpha.4
store 3.0.0-alpha.3 3.0.0-alpha.4
store-js 3.0.0-alpha.3 3.0.0-alpha.4

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants