Developing a Chrome extension. I have a class DomUtils
that I’m importing in both of my contentscripts – a
and b
.
The issue is that whenever I run the code, I get Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
This error does not occur when I comment out DomUtils
import in either of the contentscripts (a
or b
) and leave it in only one content script (So if I only import DomUtils
in a
or in b
, it works fine).
For some reason, importing DomUtils
in both my contentscripts causes this issue.
manifest.json
:
"content_scripts": [
{
"matches": ["*mysite.com"],
"js": ["a.js"]
},
{
"matches": ["anothersite.com"],
"js": ["b.js"]
}
]
And here is the mechanism for passing messages:
background.js
:
chrome.tabs.sendMessage(tab.id, { ... })
Receiving in contentScripts:
chrome.runtime.onMessage.addListener(async function(...) {
// doing some async actions...
})
I’m also using Webpack. Could the issue be related to it?