Browser.storage.local is not persistent

I noticed that every time I launch the browser and load my extension, the storage is somewhat reset, is this due to the fact that I’m debugging it or do I need sort of save the storage after putting in the data?

As long as you are using browser.storage.local.set() to save items to the storage, it should be persistent. If you are loading it as a temporary add-on for debugging, that’s probably why it’s resetting.

Isn’t the temporary add-on scenario the only option for most Android developers?

I haven’t tried it yet, but I’m surprised this is the expected process.

Do you have an id defined in your manifest? If not, every time you load the extension temporarily Firefox will treat it as an entirely new extension.

Yes I defined an Extension ID, but I think it is based on UUID and it seems it is random for temporary extensions, I’m wondering were all those left overs are saved using up disk space.

Firefox should manage storage properly automatically.

I just noticed that https://extensionworkshop.com/documentation/develop/testing-persistent-and-restart-features/ outlines some prefs you can toggle if you want to test storage.local with persistence with an unsigned extension.

Where are you reading this? I read only set an add-on ID using the browser_specific_settings key which I have done.

I have already read this, it say to us an Extension ID, i have this in my manifest file.

  • to preserve storage.local data, access to window.localStorage or indexedDB data when removing a temporary add-on (such as between browser restarts):
    • go to about:config and set both
      extensions.webextensions.keepStorageOnUninstall and
      extensions.webextensions.keepUuidOnUninstall to true .