Limit LocalStorage.setItem Attempts
vrizo opened this issue · 5 comments
Hi, @ai!
We faced NS_ERROR_OUT_OF_MEMORY
error in Firefox. It might be the incognito mode or some plugin. Unfortunately, I don't know how to reproduce the problem. It still works, but there is an issue. As I can see Logux retries to write the data all the time. I think we should limit attempts of writing to LocalStorage.
Stack trace:
function sendToTabs (client, event, data) {
if (!client.isLocalStorage) return
> localStorage.setItem(storageKey(client, event), JSON.stringify(data))
}
NS_ERROR_OUT_OF_MEMORY: No error message
at sendToTabs(./node_modules/@logux/client/cross-tab-client.js:11:16)
at leaderPing(./node_modules/@logux/client/cross-tab-client.js:22:3)
at apply(./node_modules/@logux/client/cross-tab-client.js:52:32)
at r(./node_modules/@sentry/browser/esm/helpers.js:71:23)
Firefox 72.0, Windows 10.
The error occurs every two seconds. Please let me know if I can help with the issue.
Thanks!
Seems like they were able to write to localStorage initially (isLocalStorage
is a result for initial check), but then memory was ended.
Can I ask you to help me a little with a fix here? You need to fix a few small things:
- Add
try-catch
where you will setisLocalStorage = false
and change the role toleader
on the error. - Add a test for the case.
I think this PR will help you to be familiar with Logux internals.
It would be great. Thank you! I'm quite busy this week, but I will try to send a PR on the weekend.
Fixed 0eca711
Can you use this version on Amplifr and check will it solve error? Do not forget to clean Yarn cache since you will use version from GitHub (Yarn have a problem with cache invalidation).
Thank you, @ai !
Sure! This error occurs no more than once a month. It will take some time to check.
Release in 0.6