Firefox silently fails to save to localStorage

This was first brought up in the discord:

the way the system is designed is that if you run out of quota that shouldn’t be a problem. Your localstorage for other spaces will be emptied (pruning) except for the current space. when you then return to those spaces, the cache will rebuild from the server data instead on ff, it looks like when the limit is hit, the pruning is run… but something silently fails.

additionally, even if your localstorage data doesn’t save, it should still save to teh server so that no data is actually lost. so it’s a more complex bug here.

that’s why notifying the user when the limit is hit wouldn’t actually solve anything.

or at least wouldn’t be more than a bandaid on a root problem that should be fixed.

1 Like

the pruning process looks like

        const currentSpaceId = utils.spaceIdFromUrl()
        const keys = Object.keys(window.localStorage)
        let spaceKeys = keys.filter(key => key.startsWith('space-') || key.startsWith('removed-space-'))
        spaceKeys = spaceKeys.filter(key => key !== `space-${currentSpaceId}`)
        spaceKeys.forEach(key => {

impt to note is that user data is Never cleared. The only time that localstorage is explicitly wiped is when you sign out or delete your account.

To make extra sure window.localStorage.clear() is not being hit here i’ve just added some logging when this is triggered (🚑 localStorage cleared) and extra details around what spaces are pruned when pruning happens.

So something else must be causing the localStorage to wipe, which must be specific to firefox… investigating now.

1 Like

This might be connected to firefox just deleting all ls for a domain:

it’s hard to understand but it looks like storage eviction can occur when the total size for All websites approaches a certain size. So kinopio can use 500kb, but if another website uses 10mb, that’ll cause all localstorage to be deleted?

The maximum browser storage space is dynamic — it is based on your hard drive size. The global limit is calculated as 50% of free disk space

Of if your harddrive is getting full, that’ll also trigger deletion.

firefox treating harddrive space like it’s 1999…

1 Like

this is impossible to design around, but I think I may not have to. I found a bug where the api transmitter gets the user.apikey from localstorage. Of course, when ff deletes all your data that value will be undefined.

I just released an update that uses session data for the apikey so that even if your data gets wiped underneath you all your data will save to the server. So the next time you restart (or maybe you’ll have to sign in again), all your data will be there with no data loss.

It changes a couple fundamental things, so it needs a bit of testing.

@jordanne, @bentsai
Could you try out , and let me know if that fixes the ff issue of losing cards, and lmk if this creates any data saving regressions? You can log in with your normal account and use it like you would the normal

after y’all give me the go ahead i’ll ship this for real reals.

1 Like

I have my machine in the current bad state (connected to Is there anything I can do to confirm that your hypothesis about not having the apiKey is correct?

Is your local storage empty ? If so there’s no cached user api key

1 Like

WHOOPS I’m so sorry!!! is that from my logs where it’s removed? That’s my bad. I manually wrote (removed) for my API key from the logs because I didn’t want it hanging out in plaintext in too many places (APIs generally confuse me a lot). Sorry, I should have wrote that!!

I’ll start running the preview version and let you know what happens.


No, it’s not entirely empty. There’s a user object there, with my apiKey and all.

WHOOPS I’m so sorry!!! is that from my logs where it’s removed? That’s my bad

nope my mistake :),

I missed that the user was still there in

then there’s a related problem of the space changes not saving to the server when the LS has an error. when the browser is in a bad state do you see network operations still being sent to the kinopio server?

@bentsai from this screenshot am I correct in that all spaces have been removed from ls? (including the currentspace?)

1 Like

No network operations. This in the console:

Correct, all spaces are removed from LocalStorage

1 Like

Ok got some ideas I’ll try asap and let you know when there’s a new build to try

1 Like

update released: an error on saving to ls should not interrupt saving to the server. it’s a may-or-may-not-work kind of fix so let me know if it works

1 Like

Cool, I’ll test it. I’ve switched to Firefox as my default browser and I have the devtools open. Is there a particular console message I should look for to know I’m hitting the new fix/codepath?

1 Like

following up a month later, is this still an issue that pops up?

1 Like

No I haven’t seen it. I used Firefox as my default for about two weeks.

1 Like

promising :), i’ll leave this alone for a week or so and close/resolve after that

1 Like

Unfortunately, it came up today. :frowning: Got the green notification too.


that the pruned spaces are empty is probably a clue here

1 Like

what firefox browser extensions are you running?

1 Like