ForerunnerDB
ForerunnerDB copied to clipboard
multiple instances lead to data loss
I have observed dataloss in browser and wanted to clarify it.
I am using ForerunnerDB to store some data. Data is loaded on page load from the storage, and new data is saved throughout the life of the page at different times.
The question/issue is:
When you open the same page (same URL) multiple times in different tabs on same browser, but both tabs try to save different data at different times to the storage - data will be overwritten by the last save from one tab (there by potentially loosing the previous saves by the other tab)
This leads to data loss
Please confirm and suggest a fix.
IMO, this situation doesn't happen if all instances are kept in sync - that is, if anytime new data is saved by one tab, the updates are passed to all active instances from other tabs that have loaded data from the same DB/collection. But not sure if this is currently how it works with ForerunnerDB.
duplicate #149
This is a bit of a tricky subject. We have discussed sharing data between tab instances but I have an interesting question for you:
Tab 1 opens and saves some data Tab 2 opens and saves some data
Tab 2 closes Tab 1 closes
User opens a new tab
What persistent data should the user now see? Should it be a merged view of what both tab sessions did?
When the updates are shared across the tabs (which is not happening currently) - all tabs will "show" consistent / same data, so when user opens up a new tab, there is no dilemma as to which data to show, since there is only one latest copy.
The dilemma posed by you comes because, currently when tab2 opens and saves some data, the updates are not going back to tab1 - which is resulting in data loss (the exact problem this issue is trying to address).
In our particular case, we are using collection in append only mode (it gathers new data about user actions) - so would expect the new tab to have data of tab1 + tab2 (since that is the cumulative of all user actions). When updates are implemented, when tab2 saves any new data, it will automatically notify tab1 to sync it, so in the end all three tabs (tab1, tab2 and the new tab) will eventually will have same data (the cumulative of tab1 + tab2), which is same as the expectation.