Intent to Implement: IndexedDB database enumeration API

55 views
Skip to first unread message

Andreas Butler

unread,
Sep 18, 2018, 6:43:27 PM9/18/18
to blink-dev

Contact emails

andrea...@chromium.org, dmu...@chromium.org


Explainer

https://andreas-butler.github.io/idb-databases/EXPLAINER


Design doc/Spec

https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/240.html#dom-idbfactory-databases


Summary

Adding databases enumeration function to Chromium implementation of IndexedDB to allow access to a list of current IndexedDB databases accessible by the frame’s origin.


Motivation

At present there is no standard method for retrieving a list of all existing indexedDB databases for a given frame. Providing such a list seems not only reasonable but obviously useful. Without such a list, for example, developers cannot easily iterate over all existing databases for even such basic reasons as deleting all existing IndexedDB database. (see: https://github.com/w3c/IndexedDB/issues/31#issuecomment-324756055, https://github.com/w3c/IndexedDB/issues/31#issuecomment-339070628,

https://stackoverflow.com/questions/15234363/indexeddb-view-all-databases-and-object-stores ).


There was past objection to implementing a standardized enumeration function due to its inherently racy nature (what is returned is an asynchronous snapshot of database information that may or may not be obsolete by the time it is received due to the processing of other create/delete/upgrade requests to IndexedDB). With the gradual passage of time, objections have given way to a consensus that such a feature is in fact worthwhile (https://github.com/w3c/IndexedDB/issues/31).


There was a previous nonstandard implementation of databases() in chromium named webkitGetDatabaseNames() that was deprecated due to its nonstandard nature. Its existence nonetheless made common patterns such as deleting all indexedDB instances quite simple (see: https://gist.github.com/rmehner/b9a41d9f659c9b1c3340 ).


To further emphasize the case for database enumeration with regards to database deletion, the current deletion alternatives are to use the Clear-Site-Data header, which will not only clear all IndexedDB databases, but all state associated with the current origin, or to keep meticulous records of any code that has been deployed to a given origin (even experimental code). In this case, the former solution is overkill, while the latter has been discounted by large orgs who have admitted the near impossibility of maintaining such records, and so an explicit database enumeration function will have clear benefits.


Risks:

Interoperability and Compatibility

Edge: positive signals

LGTM’d by edge PM: https://github.com/w3c/IndexedDB/pull/240

Firefox: positive signals

https://github.com/w3c/IndexedDB/issues/31#issuecomment-323635338  

Safari: Positive signals

https://github.com/w3c/IndexedDB/issues/31#issuecomment-324791267

Web developers: Positive signals

https://github.com/w3c/IndexedDB/issues/31#issuecomment-324756055 ,  

https://github.com/w3c/IndexedDB/issues/31#issuecomment-323882274 ,

https://github.com/w3c/IndexedDB/issues/31#issuecomment-339070628 ,

https://stackoverflow.com/questions/15234363/indexeddb-view-all-databases-and-object-stores  

Ergonomics

The database enumeration function will return a Promise of a Sequence of IDBDatabaseInfo objects. The IDBDatabaseInfo objects will essentially be dictionaries of informational fields relevant to the IndexedDB databases accessible by the frame.


Returning the database information as a list wrapped in a Promise was chosen over returning an IDBRequest object, contrary to what has previously been the pattern with IndexedDB functions because web development is moving in the direction of Promise-based asynchronous behaviour. As developers will not have been previously exposed to this standardized database enumeration function it is not expected that breaking the established pattern will cause serious issues. Additionally, keeping the IDBRequest object restricted to interactions with uniquely specified databases (eg: requests for opening / closing particular database instances ) was determined to be a cleaner design choice.


Activation

As this feature is fairly intuitive and simple (single function addition to existing API), it is not expected that it will be difficult for developers to take advantage of it immediately.


Debuggability

It is easy to see the list of existing IndexedDB databases using the current DevTools implementation, and thus debugging will be relatively simple for developers.


Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes


Is this feature fully tested by web-platform-tests?

Writing tests currently


Link to entry on the feature dashboard

https://www.chromestatus.com/feature/6084476278931456


Requesting approval to ship?

No


j.j.

unread,
Sep 19, 2018, 6:00:05 AM9/19/18
to blink-dev

There was a previous nonstandard implementation of databases() in chromium named webkitGetDatabaseNames() that was deprecated due to its nonstandard nature.


Joe Medley

unread,
Sep 19, 2018, 10:45:30 AM9/19/18
to fri...@jeka.info, blink-dev
Andreas,

Do you have a tracking bug for this?
Joe Medley | Technical Writer, Chrome DevRel | jme...@google.com | 816-678-7195
If an API's not documented it doesn't exist.


--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/f737e3ac-01d4-4e6f-b177-4462202903df%40chromium.org.

Joshua Bell

unread,
Sep 19, 2018, 11:46:57 AM9/19/18
to blink-dev
On Wed, Sep 19, 2018 at 3:00 AM j.j. <fri...@jeka.info> wrote:

There was a previous nonstandard implementation of databases() in chromium named webkitGetDatabaseNames() that was deprecated due to its nonstandard nature.


What's the satus? This is conflicting:

It is confusing...
 

 Deprecated in 58 / removed in 60.


This never landed; the removal did occur in 60. I'm failing to find concrete evidence of why this CL was created and abandoned; I believe in offline conversations we determined that we were okay with the removal based on further analysis. This is made particularly confusing because the code review tool changed at exactly this timeframe. :(
 

That graph makes no sense to me. The removal landed in mid-May, so 6 weeks later you can clearly see the removal hitting stable mid-late 2017 as M60 rolls out, and the feature does not exist in the code. It was not re-added. Yet the number spikes somehow when the metrics change rolls out. I'll follow up with the data pipeline owners..

 

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.

Andreas Butler

unread,
Sep 19, 2018, 2:23:27 PM9/19/18
to Joe Medley, fri...@jeka.info, blink-dev

On Wed, Sep 19, 2018 at 7:44 AM, 'Joe Medley' via blink-dev <blin...@chromium.org> wrote:
Andreas,

Do you have a tracking bug for this?
Joe Medley | Technical Writer, Chrome DevRel | jme...@google.com | 816-678-7195
If an API's not documented it doesn't exist.


On Wed, Sep 19, 2018 at 3:00 AM j.j. <fri...@jeka.info> wrote:

There was a previous nonstandard implementation of databases() in chromium named webkitGetDatabaseNames() that was deprecated due to its nonstandard nature.


What's the satus? This is conflicting:

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
Reply all
Reply to author
Forward
0 new messages