Chrome extension message passing not working (background.js to content.js)

Everything looks to be in order from what I can see in your post, so i’m just throwing ideas out:

I think the clue to the error here is the first error, not the second — it looks like the communication between the scripts hasn’t established correctly.

Possibly try changing the persistent setting of your background script to false:

"background": {
  "scripts": ["background.js"],
  "persistent": false
},

From the docs, that is only required if you are modifying network requests, using the chrome.webRequest API and may be causing some strange problem with the set up here.

But as I said, only an initial guess.

Good luck!

Leave a Comment