I need to create an object store when upgrade phase of the database passed. To achieve that, I am trying to close and reopen the database with a new version and create the store in onupgradeneeded event.
IndexedDB has a close() method that
Returns immediately and closes the connection to a database in a separate thread.
However, it does not return IDBRequest like other similar methods. This method waits for running transactions to finish, so the closing can be delayed. I need to know about the close event, so I can reopen it. There is an onclose event, that does not fire, because the connection is not closed unexpectedly:
Fired when the database connection is unexpectedly closed. Also available via the onclose property.
I don't want to be rude to periodically check the onblocked event in opening attempts. In my tests IndexedDB.open() reopens the database succesfully, but I can't push it to production if it is not guaranteed. In the w3 specs they write about done flag, but I can't find it in the browser console.