@Jackie Han, your observation is definitely relevant too . A while ago I did a search and found the link you suggested.
I understood that the browser can evict the data of a source without any warning when the latter exceed a certain limit unless a particular permission is requested (and granted).
If I remember correctly this permission is requested with "navigator.storage.persisted()".
In the world of extensions, the danger of this unannounced emasculation would not seem concrete (I await confirmations or denials).
I also checked that invoking
navigator.storage.persisted() from inside an extension does not give any grant.
However, we can run into an error when you exceed the quota limit.
I made some changes as @wOxxOm suggested.
Now you can choose whether to operate in "strict" or "relaxed" mode.
Now I no longer save numbers but an object with other nested objects inside (up to the second level).
What to say? IDB performance improves and NOT A LITTLE!
Now IDB is playing on equal terms with storage.local even if, by a small margin, the latter still wins (at least in my opinion).
It remains, at least for me, to clarify what is meant by "relaxed".
Mozila says: "Using "relaxed" provides better performance, but with fewer guarantees. Web applications are encouraged to use "relaxed" for ephemeral data such as caches or quickly changing records,
and "strict" in cases where reducing the risk of data loss outweighs the impact to performance and power."
Mozilla doesn't go into detail about "when" the data will be persistently saved to disk.
I mean, let's say I fill a
100Mb
IDB, wait for the transaction to be committed (either with the dedicated event or with a promise) and then I close the browser after 5\10 seconds.
What should I expect when the browser restarts? The updated db, the one before this heavy transaction or even worse the damaged db?
Next step: "quite massive" transactions on IDB from inside the SW.
The previously created link has been invalidated.