I\'m developing an extension in Chrome, and there\'s a problem. In my inject.js, I make a request like:
chrome.extension.sendRequest({command:
After some time spent on investigation I found the problem in my case.
I'm also getting:
Port error: Could not establish connection. Receiving end does not exist.
Before explaining, I want to say that I'm using sendMessage and onMessage for communication.
For me this error appear when I'm sending a message from the background page to one tab where my content script is running.
My extension runs only on tabs where youtube is open. So when I'm changing some preferences I'm looking to see what tabs I have open and send a message to update updated preference.
In a normal case it works fine, but if I have n (n >= 1) tabs with youtube open. I click in "Reload" button for extension, I change something ... youtube tabs are not refreshed and they lost message listener so I'm getting this error.
It seems that is pretty normal.
If I refresh youtube tabs after extension reload I don't get this error.
I found one solution, it may not apply for all cases:
When I had this issue my code was:
chrome.tabs.sendMessage(tabId, {proprName: proprName, newValue: newValue}, function(response) {});
Now my code is:
chrome.tabs.sendMessage(tabId, {proprName: proprName, newValue: newValue});
For my I didn't needed response callback and because that was not responding I had this error.