question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Limit LocalStorage.setItem Attempts

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aicommented, Jan 29, 2020

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:

  1. Add try-catch where you will set isLocalStorage = false and change the role to leader on the error.
  2. Add a test for the case.

I think this PR will help you to be familiar with Logux internals.

0reactions
aicommented, Feb 10, 2020

Release in 0.6

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the max size of localStorage values? - Stack Overflow
upperLimit is 1GB by default, and just limits how far upwards to scan exponentially before starting the binary search. I doubt this will...
Read more >
What is the max size of localStorage values? - GeeksforGeeks
localStorage limit in your Browser is 5000 KBs. Explanation: This javascript code will run by adding continuously increasing length strings ...
Read more >
LocalStorage, sessionStorage - The Modern JavaScript Tutorial
Both key and value must be strings. The limit is 5mb+, depends on the browser. They do not expire. The data is bound...
Read more >
Browser storage limits and eviction criteria - Web APIs | MDN
The maximum browser storage space is dynamic — it is based on your hard drive size. The global limit is calculated as 50%...
Read more >
Using JavaScript to fill localStorage to its maximum capacity
How to programmatically fill localStorage and sessionStorage to their maximum capacity using JavaScript (mainly for testing purposes).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found