indexedDB.deleteDatabase doc: Mention that deleting a database isn't completed until the upgradeNeeded result is closed
#20,368 创建于 2022年9月7日
仓库指标
- Star
- (8,900 star)
- PR 合并指标
- (平均合并 7天 3小时) (30 天内合并 147 个 PR)
描述
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
- Folder:
en-us/web/api/idbfactory/deletedatabase - MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/deleteDatabase
- GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/idbfactory/deletedatabase/index.md
- Last commit: https://github.com/mdn/content/commit/916af5e72ce683c6f7795755830c11677ca0f529
- Document last modified: 2022-08-04T06:19:25.000Z