Skip to content

refactor(store): hold a weak reference on store - #3156

Draft
Legend-Master wants to merge 1 commit into
tauri-apps:v2from
Legend-Master:store-weak-check
Draft

Legend-Master wants to merge 1 commit into
tauri-apps:v2from
Legend-Master:store-weak-check

Conversation

@Legend-Master

@Legend-Master Legend-Master commented Dec 9, 2025 •

Copy link
Copy Markdown
Contributor

Option 3 of #3145 (comment)

We now always hold onto a weak reference on the Store until all the strong references to it get dropped, this ensures that we will only ever have 1 Store for a single path (except for when the user uses create_new)

This is similar to the implementation from the beginning of #1860

Not sure if it's worth it to be honest though

@github-actions

github-actions Bot commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

Package Changes Through 6146142

There are 21 changes which include dialog-js with minor, dialog with minor, log with minor, log-js with minor, localhost with patch, barcode-scanner with patch, barcode-scanner-js with patch, deep-link with patch, deep-link-js with patch, fs with patch, fs-js with patch, http with patch, http-js with patch, nfc with patch, nfc-js with patch, updater with minor, updater-js with minor, upload with minor, upload-js with minor, websocket with patch, websocket-js with patch

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 2.0.38 2.0.39
api-example-js 2.0.34 2.0.35
deep-link-example-js 2.2.8 2.2.9
barcode-scanner 2.4.2 2.4.3
barcode-scanner-js 2.4.2 2.4.3
deep-link 2.4.5 2.4.6
deep-link-js 2.4.5 2.4.6
fs 2.4.4 2.4.5
fs-js 2.4.4 2.4.5
dialog 2.4.2 2.5.0
dialog-js 2.4.2 2.5.0
http 2.5.4 2.5.5
http-js 2.5.4 2.5.5
localhost 2.3.1 2.3.2
log 2.7.1 2.8.0
log-js 2.7.1 2.8.0
nfc 2.3.3 2.3.4
nfc-js 2.3.3 2.3.4
persisted-scope 2.3.4 2.3.5
single-instance 2.3.6 2.3.7
updater 2.9.0 2.10.0
updater-js 2.9.0 2.10.0
upload 2.3.2 2.4.0
upload-js 2.3.2 2.4.0
websocket 2.4.1 2.4.2
websocket-js 2.4.1 2.4.2

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


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

let state = app.state::<StoreState<R>>();
let mut stores = state.stores.lock().unwrap();
if let Some(rid) = validate_resource_id(&app, stores.get_mut(&store.path)) {
let _ = app.resources_table().close(rid);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically not safe since we didn't hold a lock through out and the resource id can be reused (tauri-apps/tauri#9272) ...

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.

1 participant