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

how to "re-establish" a key-value index that was deleted by the user #159

Open
EdmundsEcho opened this issue Oct 31, 2022 · 3 comments
Open

Comments

@EdmundsEcho
Copy link

I use idb-keyval to track user-driven changes in the ui-state (e.g., whether to show a detailed view of a component). The ability to write to a db does not depend on the initial presence of a db (the api just creates a new instance)... except when the user has deleted the key-val index in the dev-console/Storage tab.

The only solution/hack I have found thus far is to change the name of the db. This seems to be because a db can only have one "table"/index. So, deleting an index effectively requires a new db.

To be more specific with the issue, the starting state in "Storage" is db-ui-state/tbl-stateid-value where the idbStore was initialized as follows:

// DB = db-ui-state, TBL = tbl-stateid-value
const idbStore = createStore(DB, TBL);

If I delete tbl-stateid-value, the app subsequently generates errors when I would expect that it "re-establish" the instance.

Has anyone encountered this situation? How might I re-establish the ability to write to the deleted index?

@scamden
Copy link

scamden commented Jun 2, 2023

@EdmundsEcho how are you able to delete that? in my chrome devtools panel i can only "clear" the table or delete the whole DB

@EdmundsEcho
Copy link
Author

EdmundsEcho commented Jun 16, 2023

It happened in Firefox. I'm not sure I tried to replicate in chrome and others. I'll see if I can compare the "delete" options. Maybe Firefox enables a more "severe" delete.

@Ulisseus
Copy link

Ulisseus commented Feb 22, 2024

It's a very unlikely case but in Firefox user can manually drop the store which can cause all sorts of problems. Unfortunately, even closing the tab or restarting the browser does not fix it.

@EdmundsEcho how are you able to delete that? in my chrome devtools panel i can only "clear" the table or delete the whole DB

Something like this. There is a DB 'coh_external_cache' with store 'responses'

image

Afterwards the DB is still there (or maybe recreated) but the store is missing, so every set request to this store fails. It would be nice if the missing store was recreated on such errors. But again it's a such bizarre scenario (user manually doing something trough dev tools in certain browser), so I just wrote it off.

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

No branches or pull requests

3 participants