Porting an existing extension from chrome to edge and I'm having issues with the 1mb limit on chrome.storage.local. I used the function in this topic String length in bytes in JavaScript to find he size of the string and found if the json string is over 1mB it will throw a "over 1mB" exception, but if the json string was between 250kB and 1mB I get a message in chrome.runtime.lastError saying the data is over 1mB, no exception is thrown and the data is not stored.
I tried switching to browser.storage but I'm getting the same results. Is this a bug or is the byte size function I'm using wrong?
Also I'm using lz-string to compress the data to try and increase my storage.
tmp = JSON.stringify(tmp);
tmpAsString = LZString.compressToUTF16(tmp);
var compresskey = 'compressedJSExtension';
try {
chrome.storage.local.set({[compresskey] : tmp }, function () {
if (chrome.runtime.lastError) console.error(chrome.runtime.lastError);
});
}
catch (f) {
//Handle if the string is over 1mB
}