Startup freeze (deadlock in tauri-plugin-store) when more than 20 playlists are loaded/saved in a burst
Summary
With more than 20 local playlists, Nuclear freezes for good at startup when a plugin writes all of them in a row. In my case it was the Subsonic plugin with "Sync playlists" on and 21 playlists on the server. The window stays up, nothing responds, and the MCP server times out on every call. The log stops right after [plugins] Checking for plugin updates.... There is no crash, so no crash report either.
It is a deadlock in tauri-plugin-store 2.4.4. PlaylistFileStore's LRU eviction triggers it, because it calls close() on a store while other stores are still loading.
Environment
- Nuclear 1.54.2, macOS 26.5.2 (Apple Silicon)
Cargo.lockon master:tauri2.11.5,tauri-plugin-store2.4.4,wry0.55.1- 21 playlists in
playlists/, the Subsonic plugin 0.6.2 withsyncPlaylistson
Steps to reproduce
- Have more than 20 playlists, from any source.
- Do anything that loads or saves more than 20 playlists in a short burst. In my case, playlist sync from
nuclear-plugin-subsonicruns at startup and saves every playlist. - The app freezes. It reproduces 100% for me. Turning the plugin's playlist sync off makes startup work again.
Stack (sample of the frozen process)
Main thread, inside the sync resources|close command:
tauri::resources::plugin::close
tauri::resources::ResourceTable::close
<tauri_plugin_store::store::Store as Resource>::close
std::sys::sync::rwlock::queue::RwLock::lock_contended
One tokio worker, inside load:
tauri_plugin_store::store::StoreBuilder::build_inner
tauri::manager::AppManager::resources_table
std::sys::pal::unix::sync::mutex::Mutex::lock (waiting)
Seven more tokio workers are blocked in build_inner on the same RwLock. One more is stuck in InvokeResolver::return_result → WKURLSchemeTask didReceiveResponse → callOnMainRunLoopAndWait, which waits for the blocked main thread.
This is a lock-order inversion:
Store::closeholds the resource table mutex, then takesstores.write().- In 2.4.4,
build_innerholdsstores.write()for the whole build, then locks the resource table.
close is a sync command, so it runs on the main thread and the UI never comes back. This exact bug was fixed upstream in tauri-apps/plugins-workspace#3746 ("fix(store): take the resource table and stores locks in one order", merged 2026-11-05). As far as I can see the fix is not on crates.io yet: the latest 2.x is 2.5.0, from 2026-09-26.
Why Nuclear hits it
packages/player/src/services/playlistFileService/PlaylistFileStore.ts keeps at most MAX_CACHED_STORES = 20 LazyStores. On each access, #touch() fires void this.#evict(), and #evict() calls store.close() on the least recently used one, without awaiting it and without checking whether a load is still in flight. Once a burst touches a 21st playlist, a close runs at the same time as the loads of other playlists. That is exactly the load/close race above.
Below 20 playlists nothing is ever evicted, which is probably why nobody has reported it.
Possible fixes
- Bump
tauri-plugin-storeto the first release that includes #3746, or pin the git revision until it ships. This removes the deadlock itself. - Make eviction safe in
PlaylistFileStore, independent of the plugin version:- track the pending operation per store, and only
close()once that store's in-flightload/set/savehas settled; - serialize
#evict(), soclose()never runs at the same time as aload, for example with a simple promise queue; - or skip the eviction: one
LazyStoreper playlist is small, and the cap of 20 is low for people with large libraries. Raising it, or closing only on idle, would sidestep the race in practice.
- track the pending operation per store, and only
- Defensive: a
close()that throws or hangs during eviction should not block the app. Log it and drop the reference.
The Subsonic plugin could batch its writes too. But any plugin, or the user, can trigger this by touching more than 20 playlists quickly, so the root fix belongs here and in the store plugin.
I can provide the full sample output if useful.