Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimistic cache not purged on database deletion #1736

Closed
dfahlander opened this issue Jun 9, 2023 · 2 comments
Closed

Optimistic cache not purged on database deletion #1736

dfahlander opened this issue Jun 9, 2023 · 2 comments
Labels

Comments

@dfahlander
Copy link
Collaborator

If components are live-querying data and an action does Dexie.delete(database) or db.delete(), the optimistic cache isn't wiped out.

See #1689 (comment)

@b-straub
Copy link

b-straub commented Jul 1, 2023

Any news on this?

@dfahlander
Copy link
Collaborator Author

dfahlander commented Jul 4, 2023

The solution does wipe the cache on reopen. Ongoing live queries will not be triggered at the time of database deletion, but rather at the time when a database has been created. In case a database is deleted and then recreated, the cache will be wiped out on successful open and the ongoing queries will be retriggered.

A deletion without reopening the database will leave ongoing live queries as they are. If they are retriggered for another reason (state update in app etc), they might auto-open the database and get the results from a recreated database.

If app code wants to delete database and force it to not reopen automatically, application code must do both db.close() and db.delete(). All queries after that will then fail with database closed error, but not immediately and only if a liveQuery is triggered from a non-dexie reason such as a state update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants