w3c / IndexedDB

Indexed Database API
https://w3c.github.io/IndexedDB/
Other
240 stars 62 forks source link

deleteDatabase No Response #406

Closed zizxzy closed 1 year ago

zizxzy commented 1 year ago

When I use the following code to create a new IndexedDB on my Edge browser.

const request = window.indexedDB.open('personDB', 1)
var db
request.onerror = function(error) {
  console.log('IndexedDB open fail', error)
};

request.onsuccess = function(res) {
  console.log('IndexedDB open success', res)
  db = res.target.result
}

request.onupgradeneeded = function(res) {
  db = res.target.result
  if (!db.objectStoreNames.contains('person')) {
    const db_table = db.createObjectStore('person', { keyPath: 'id' })
    db_table.createIndex('indexName', 'name', { unique: false })
  }
}

And then I use the following code to output all database.

const promise = indexedDB.databases();
promise.then((databases) => {
  console.log(databases);// 
});

image But when I use the following code to delete database,it do not work.

const deleteRequest = window.indexedDB.deleteDatabase('personDB')
deleteRequest.onerror = function (event) {
  console.log("delete fail")
}
deleteRequest.onsuccess = function (event) {
    console.log("delete success")
}

After a long time, there is still no output 'delete success'. image

inexorabletash commented 1 year ago

Hey @zizxzy - this repo is about the specification. It sounds like you're having trouble with the implementation. Consider using a peer support forum like StackOverflow. If you think you're seeing an implementation-specific issue, file a bug against the specific browser (Firefox, Chrome, Safari, Edge, etc).

In your particular case, if you're not seeing a success or error event from the deleteDatabase() call it is likely that there is an existing connection to the database. You can observe this by listening for a blocked event against the request, and ensure that the open connection is closed, either by closing it immediately after you're done using it, or in response to a versionchange event fired at the connection.