-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local storage sometimes outdated without hard refresh. Should re-fetch all data if localStorage timestamp is older than server copy. #846
Comments
Actually, I think something else is going on with the back button. I lost my work, started re-writing what I had lost, then tried to add a new file and got a Internal Server Error. I then refreshed, and got my original, unlost state back on reload. This implies back->forward navigation is loading a stale state not from the server? |
I've run into this problem several times now. It seems the app is prioritizing some old localStorage state even when remote is updated. Each time I "lose" progress, I do a hard refresh and see my updated files. Perhaps a timestamp check is in order on load where the localStorage can be compared to the live data + re-fetch if old? Optionally only if browser history is in latest state, though I question if being able to go "back" at all would ever make sense. |
Hmm, that is interesting. We don't put any files of the editor in the
OH, I think that I know what it could be! Our Service Worker caches API responses, so if you load a sandbox without internet connection it will load the latest known version of the sandbox, which can be older. Hmm, yes, this is indeed bad behaviour, because it can behave flakey on bad connections. The best solution would be to save it in localStorage and do a timestamp comparison. I'm not sure if I can get the time this week to work on it, but next week I can take a proper look! |
Hey @yuchant , Is this still an issue for you? |
Closed for lack of activity |
🌈 Feature
I have been using codesandbox for only 30 hours, and have lost my changes numerous times due to completely accidental backwards swipes. I've rewritten quite a lot of code due to accidental back navigation.
This last instance felt like at least 3+ minutes of data lost.
Codesandbox should save unsaved history into local storage as much as possible. Not a true "save" but a state save.
If there are performance considerations on too many saves, it could be hooked into things like file selection, new tab selection, a long poll, or on the
onbeforeunload
event.Thank you for your awesome work!
The text was updated successfully, but these errors were encountered: