I’ve implemented an options-page in my addon that allows to configure how the frontend behaves. Before publishing the addon on addons.mozilla.org and assigning a unique addon ID, this worked flawlessly.
Now that I’ve published the addon, saving new settings doesn’t work properly anymore, no matter if running the published addon or my development environment via web-ext. Sometimes the addon options page throws an “TypeError: can’t access dead object” exception or after about 20 seconds some error message with “session id” is appearing.
Settings will be saved seemingly randomly after a minute or so, sometimes changes are completely lost.
I can only assume, that saving the settings via browser.storage.sync.set somehow doesn’t work anymore now that the addon is “live”. I use the following command:
return browser.storage.sync.set({
'settings': this._settings
});
this._settings is a very small JSON that only consists of a few strings, integers and arrays.
In the frontend I gain access to the settings via initally loading them with browser.storage.sync.get(‘settings’) into an object, then accessing the values within.
I use the latest Firefox Developer Edition. Happens also in non-developer editions.
Addendum:
Currently I call browser.storage.sync.set at any point when the settings change. Maybe this is the problem?
Is it better to use browser.storage.local.set and browser.storage.local.get for regular use in my addon, and only use browser.storage.sync.set and browser.storage.sync.get once in while?
E.g. only sync when the extension is updated, or every few hours, something like that.