14

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.}

12
  • It's not really clear from what you've provided whether your snippet and the error are related. Commented Dec 17, 2016 at 9:51
  • It's related I used the debugger and this error showed right after the call to the storage API. this is a simplified version of the code. Commented Dec 17, 2016 at 9:53
  • 1
    Well, you're going to have to come up with a minimal reproducible example that demonstrates the problem because as it is, there isn't any clear way anyone can help you other than simply guessing. Commented Dec 17, 2016 at 9:55
  • This is the minimal and complete example, what the error message says? I couldn't track it down, it points to the storage API call. Commented Dec 17, 2016 at 9:58
  • 2
    This is obviously not a minimal reproducible example. There's no easy way for anyone to reproduce this and your error message is obviously from a larger codebase. Commented Dec 17, 2016 at 10:09

3 Answers 3

30

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.

Sign up to request clarification or add additional context in comments.

1 Comment

This helped some times, the solution by @deprog (disable-reenable) other times.
14

I was also getting this same error. I fixed it by disabling and re-enabling my Chrome browser extensions. Hope that helps.

1 Comment

This helped some times, the solution by @Sudheer (unset debugging breakpoints) other times.
1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.