Kerrick/Mostly-Harmless — Issue #25: Exceeding the localStorage quota breaks Mostly Harmless.
Author: Kerrick
Created: 2011-10-23 13:19:27+00:00
State: open
Labels: Level - Urgent, Status - Roadmap, Type - Confirmed bug

Currently, Mostly Harmless clears the cache every time the browser is restarted. Unfortunately, if a user leaves the browser open for a _long_ time and loads _huge_ number of pages, the ~2.5 MB quota Google Chrome gives each domain (extension) for `localStorage` can be exceeded. This is not handled gracefully; An uncaught error is thrown: `QUOTA_EXCEEDED_ERR: DOM Exception 22` on `background.html`, and Mostly Harmless's browser action icon never gets its text, popup, or tooltip customized, even if the API call is successful. Instead, it appears to be loading.

A quick fix would be to move a `try`/`catch` block around the caching functions. The extension could at least show an error instead of appearing to load until the browser is restarted.

A better fix would be to run a "cron job" at the interval specified in `settings.cacheTime`, and clear the cache of all data that is both older than the cache time, and not relevant to a currently opened tab. It would also be possible to add a _Clear Cache_ button to the preferences under Performance > Cache Time.