Closed Bug 1285781 Opened 6 years ago Closed 5 years ago

Mobile twitter web site hits localStorage cap and breaks silently


(Web Compatibility :: Desktop, defect)

Firefox 49
Not set


(platform-rel +)

Tracking Status
platform-rel --- +


(Reporter: kael, Unassigned)




(Whiteboard: [needsdiagnosis][platform-rel-Twitter])

I'm not sure if this is a recent change/regression, but in Firefox if you use Mobile Twitter long enough, it hits the local storage quota and silently breaks. After this happens various features on the site don't work anymore, like replying to tweets or marking them as favorite.

If you open the web console after this happens there's nothing there, but if you have the console open before it happens the first time you get the quota error:

NS_ERROR_DOM_QUOTA_REACHED: Persistent storage maximum size reached

Looking at localStorage showed two keys in the site's local storage:

> localStorage.twitter.length
> localStorage["85d75cba23346a489aa4f86bb13408750942d334"].length

Both keys appeared to be JSON blobs, with the large one being a huge bundle of stuff I couldn't easily identify as a specific thing. A cache, maybe?

localStorage.clear() fixed the problem.

I expect this is also going to break in Android Firefox, and in that case it will be much harder for the user to fix it.

This may be a difference from other browsers like Safari or Edge or Chrome, since in this case it appears that under 2MB of text in localStorage was enough to hit quota. I was under the impression that quota for localStorage is normally 5MB. IIRC Chrome uses two-byte representation for localStorage data, though, so its cap is around 2.5MB?
It looks like the linked JS is using sessionStorage:

function a(e, t) {
    try {
        null == t ? window.sessionStorage.removeItem(o(e)) : window.sessionStorage.setItem(o(e), JSON.stringify(t))
    } catch (n) {
        if ( === c) return;
        if (l.indexOf( >= 0 && 0 === window.sessionStorage.length) return;
        throw n

l is defined as l = ["QuotaExceededError", "QUOTA_EXCEEDED_ERR"]).... if is "NS_ERROR_DOM_QUOTA_REACHED", then I guess we won't hit the early return. Maybe?

From, QuotaExceededError is current (and appears to be what Chrome throws) and QUOTA_EXCEEDED_ERR is the legacy one (and is what Safari throws).
Mike, any suggestions or further investigation?
Flags: needinfo?(miket)
Whiteboard: [needsdiagnosis]
platform-rel: --- → ?
Whiteboard: [needsdiagnosis] → [needsdiagnosis][platform-rel-Twitter]
platform-rel: ? → +
Rank: 50
Just took another peek, and it looks like the code has changed quite a bit:

storeData: function(a, b) {
  try {
    sessionStorage.setItem(a, b)
  } catch (c) {
    if ( !== "QuotaExceededError" && c.message !== "QuotaExceededError" && !== "NS_ERROR_DOM_QUOTA_REACHED" && !== "QUOTA_EXCEEDED_ERR" && c.number !== -2147024882)
      throw c;
    this.logWithStorageException(c, b)

I think we can probably just close this as WFM -- but if you run into this again kael, please let us know and we can pick up investigation!

(Assuming that was the right bit of code to look at -- has a nice "app/utils/storage/core" module using localStorage, but there's try/catches in all the right places, AFAICT)
Closed: 5 years ago
Flags: needinfo?(miket)
Resolution: --- → WORKSFORME
Product: Tech Evangelism → Web Compatibility
You need to log in before you can comment on or make changes to this bug.