Hello,
I’ve just faced quite difficult situation after I decided to use IndexedDB also from my extension page.
In my new version I did a database upgrade and updated onupgradeneeded
handler - in my background script. However I didn’t include this handler in my extension page, because it won’t initialize database until it receives custom ready
message from the background script which happens only after DBOpenRequest.onsuccess
handler fires (which is after IndexedDB upgrade happens).
Now what happened is that for some users the database was not upgraded! This could only happened if extension page opened database with new version number which would lead to inconsistent state due to missing onupgradeneeded
handler (I’ve upgraded database several times before and this is first time I faced this problem).
I want to know how is this possible.
I’ve just validated that even with 10 seconds delay in my background script - the extension page won’t touch database, so there is no way this is a race condition.
The only possibility is that the extension page
was updated and opened BEFORE background script was updated or that the old background script was still running.
Can somebody explain how update process work behind the scenes?
I don’t have onUpdateAvailable
listener so the update should not happen when Firefox starts.
I remember I’ve filed a bug related to update process some time ago: https://bugzilla.mozilla.org/show_bug.cgi?id=1436041