mdn/content

indexedDB.deleteDatabase doc: Mention that deleting a database isn't completed until the upgradeNeeded result is closed

Open

#20,368 opened on 2022年9月7日

GitHub で見る
 (2 comments) (0 reactions) (0 assignees)Markdown (22,427 forks)batch import
Content:WebAPIaccepting PRarea: IndexedDBhelp wanted

Repository metrics

Stars
 (8,900 stars)
PR merge metrics
 (平均マージ 7d 3h) (30d で 147 merged PRs)

説明

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/deleteDatabase

What specific section or headline is this issue about?

No response

What information was incorrect, unhelpful, or incomplete?

When calling IDBFactory.deleteDatabase(), the database isn't deleted until the upgradeneeded event is garbage collected, which can by triggered by calling request.result.close() on the indexedDB.open() result.

What did you expect to see?

Mention that onsuccess won't be fired until the indexedDB.open() result is closed like so:

const request = indexedDB.open(dbName);
request.onupgradeneeded = () => {
  request.result.close();
}

though to be honest I'm not sure how much of this depends on my specific situation. I reckon there might be other calls that similarly cause a database to stay open like this.

Do you have any supporting links, references, or citations?

Initially I thought this was a bug in Chrome, so I reported https://bugs.chromium.org/p/chromium/issues/detail?id=1359843. But it seems like this behaviour is intentional. You can find an example of this behaviour at https://indexeddb-deletedatabase-hanging.glitch.me/ you'll see that unless you have the 'close indexedDB.open() result' checkbox checked, deleting databases will take significantly longer depending on how fast the objects are garbage collected.

Do you have anything more you want to share?

No response

MDN metadata

コントリビューターガイド