I have a weird issue that wasted too much time. I have content script that tries to read some data from the storage.sync API but it fails.
I've added the storage permission and I was able to work with the storage.sync API in the options.js file.
Can you spot what went wrong?
document.addEventListener('DOMContentLoaded', function () {
chrome.storage.sync.get([
'var1',
'var2',
], function(items) {
alert("got it");
});
}
This is the error message:
CONTENT_SCRIPT context for xxxxx) Lazy require of extension.binding did not set the binding field
(CONTENT_SCRIPT context for xxxxx) extensions::lastError:82: Uncaught TypeError: Cannot convert undefined or null to object{TypeError: Cannot convert undefined or null to object at Object.clear (extensions::lastError:82:23) at handleResponse (extensions::sendRequest:84:15) at restore at HTMLDocument.}
User data can be automatically synced with Chrome sync (using storage. sync ). Your extension's content scripts can directly access user data without the need for a background page.
One way to share data between a background script and the other scripts that make up the extension is to save the data to a location which is accessible to all the scripts in the extension. We can use the browser localStorage API or chrome. storage which is specific to Chrome extensions.
sync , the stored data will automatically be synced to any Chrome browser that the user is logged into, provided the user has sync enabled. When Chrome is offline, Chrome stores the data locally. The next time the browser is online, Chrome syncs the data. Even if a user disables syncing, storage.
I had the same error and it was caused due to debugger stopping the flow of execution in the middle. Once I removed the debugger / breakpoints in my 'Content Script' and 'Background Script' and reloaded everything then I didn't see the error.
I was also getting this same error. I fixed it by disabling and re-enabling my Chrome browser extensions. Hope that helps.
I had the same problem when injecting code into a html page. Using new id's immediately after injecting them into the page html seems to crash the debugger but not the page itself. Everything works and the error message only pops once on injecting the code. It looks like it was coming from the cache. It just happened once on refreshing the page and never after clearing cache... Sorry not very useful, but this is what I had and could not reproduce anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With