In a browser extension we store a serialized JSON in the browser local storage. using storage.local.set({ accounts: JSON.stringify() })
When loading the data from the storage again using storage.local.get
we use JSON.parse
to deserialze the data. This works fine in Chrome and Firefox.
It seems Orion is automatically parse the JSON and return an object (this breaks code that assumes it has to parse the JSON).
Code that writes to the storage: https://github.com/getAlby/lightning-browser-extension/blob/master/src/common/lib/cache.ts#L14-L16
Code that reads from the storage: https://github.com/getAlby/lightning-browser-extension/blob/master/src/common/lib/cache.ts#L6-L9
Everything works if I check the type of the stored data:
accountsCache = typeof result.accounts === 'string' ? JSON.parse(result.accounts) : result.accounts;
I assume this should behave the same as in Chrome of Firefox
Steps to reproduce:
write to storage.local and read from storage in an extension:
browser.storage.local.set({ accounts: JSON.stringify({foo: 'bar'}) });`
const result = await browser.storage.local.get(['accounts']);
console.log(result.accounts); // this should be a string and not an object
JSON.parse(result.accounts);
Expected behavior:
expected the storage.local.set
and storage.local.get
function to behave the same as in other browsers and return the JSON string.
Orion, OS version; hardware type:
Version 0.99.121-beta (WebKit 614.1.20)
MacBook Air (macOS Monterey 12.5.1 build 21G83)