in-memory fallback for localstorage

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

We recently found a bug where if local storage isn't available, we threw some exceptions.

I fixed this in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10937 by adding some conditionals to avoid exceptions.

@andrewn Shared that Gitter has worked around this before using an in-memory fallback for localStorage. This is a great idea especially considering we do have a case that uses localStorage for perf improvements which could probably still retain some of the performance benefits from a memoization fallback.

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10937#note_28643880

For what it's worth, Gitter has a similar workaround, with the exception handling encapsulated inside a component with an in-memory-only fallback shim for when localstorage isn't working:

https://gitlab.com/gitlab-org/gitter/webapp/blob/develop/public/js/components/local-store.js

Instead of using localStorage directly, it's always done via the component, which is guaranteed to be safe (no need for try-catch etc in app logic):

Edited Sep 28, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading