rhoward
rhoward

Reputation: 313

Deleting an Indexeddb database - Chrome getting stuck

I have an indexeddb database that I am trying to delete programatically.

My code looks like this, however I also tried to delete it using idb.deleteDB() and got the exact same end behaviour:

                var DBOpenRequest = indexedDB.open("team-pwa"); // opening a database.

                DBOpenRequest.onerror = function(event) {
                  console.log("Error loading database");
                };

                DBOpenRequest.onblocked = function(event) {
                    console.log('blocked');
                    console.log(event);
                }
                DBOpenRequest.onsuccess = function(event) {
                    console.log("success loading database");

                  db = DBOpenRequest.result;

                  db.close();
                  indexedDB.deleteDatabase('team-pwa')
                };

The behaviour I end up with is that I can still see the indexeddb database listed in devtools->application but if I select it, no information is displayed. This means I can't even manually delete the database any more and I have to do so through "clear browsing data".

In this state, I can't interact with the database api either. I don't get any errors, in my console, I just get... silence.

I'm getting the same behaviour on a Ubuntu machine and a Windows one.

Is this a chrome bug or am I doing something daft? Has anyone got a work around?

UPDATE: it behaves properly (no issues) in Firefox.

Upvotes: 4

Views: 684

Answers (1)

Andreas Aanestad
Andreas Aanestad

Reputation: 28

This is an issue with Chrome. I experienced the same issue and reverted to a version of my code that had handled this correctly, but the problem was still there. Closing all instances of Chrome should fix it, but if the problem repeats itself then I would suggest giving us a look at your code.

Upvotes: 0

Related Questions