We have some data stored in localstorage
and we are using window.setInterval()
to regularly update it every minute. In this interval we are continuously reading and writing the data.
Is it possible that concurrency issues can occur because we're using setInterval()
, as multiple tabs can modify the data in localstorage
simultaneously?
Edit 1: Explaining the scenario in detail:
Each tab is writing some data to localstorage
against a key (say xyz
) and also setInterval()
, present in the running javascript, continuously checks the xyz
key data. If some data exists against the key, then the setInterval
callback sends it to the back end. Each tab running the same script will read the xyz
key and append some data to the existing value after performing some logic.
I doubt that a concurrency issue may occur, like one tab may be reading the xyz
key and adding data to the local storage and another tab might be doing the same thing at the same time. Now both will try to send the data at the same time, hence I may receive the same data 2 times in the back end.