[SPIP] fix: DataEntry app not loading due to sessionStorage limits#83
[SPIP] fix: DataEntry app not loading due to sessionStorage limits#83MatiasArriola wants to merge 1 commit into
Conversation
If I understand it correctly, And then we can interact with the object, using that new key. The only expectation is that the object should have the prop "id", which will be used as retrieval key: > DAO.store.set("metadata", {id: "1234", name: "Mary"})
> DAO.store.get("metadata", "1234").done(console.log);
Object { name: "Mary", id: "1234" }In any case, check with @Ramon-Jimenez if we prefer the simple memory cache. |
|
Thanks for the feedback! Just to add a little bit of context, I considered it was a good tradeoff to keep things simple and avoid making extra changes, adding some risk for little benefit. Adding indexedDb needs the following extra changes:
Looks like sessionStorage is not used as a mean for caching, but as a fallback in case the request fails. If the value is not there (first request), the program will fail anyway because it will be With this patch, it would fail the same way, with the difference the "fallback" values will be lost on page reload, which looks like a rare scenario. I went ahead and implemented an alternative fix leveraging indexedDb here: 2.40.4.1...EyeSeeTea:dhis2-core:fix/dataentry-sessionstorage-limit-idb I created a separate Tested different scenarios and both approaches seem to work fine. |
|
@MatiasArriola , Thanks for the thorough analysis! Indeed we have to be aware of the caching issues of introducing indexedDb. |
tokland
left a comment
There was a problem hiding this comment.
This in-memory approach is fine for a simple approach if we don't want headaches with the cache.
Related Issue: https://app.clickup.com/t/8698nqxmt
When loading the DataEntry app as a user with access to a large set of metadata, the app won't load if the size of the metadata response exceeds the 5mb sessionStorage quota allowed by browsers.
fix: use variables instead of sessionStorage to avoid the
QuotaExceededError.At first tried using indexedDb as a replacement, but since I couldn't find references to these sessionStorage keys anywhere else, a simpler approach is to use common in-memory variables.