Uncaught Error: Extension context invalidated.

Hi, I'm getting the following error:
Uncaught Error: Extension context invalidated.
Uncaught Error: Extension context invalidated.
And I'm sending messages when an
iconEle
iconEle
is clicked from
content.ts
content.ts
to
background.ts
background.ts
like this: content.ts
iconEle.addEventListener('click', () => {
chrome.runtime.sendMessage({ type: 'iconClicked' })
});
iconEle.addEventListener('click', () => {
chrome.runtime.sendMessage({ type: 'iconClicked' })
});
background.ts
chrome.runtime.onMessage.addListener((message) => {
if (message.type === 'iconClicked') {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { ...message });

});
}
});
chrome.runtime.onMessage.addListener((message) => {
if (message.type === 'iconClicked') {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { ...message });

});
}
});
So, for any reason after a while, I get the error on the screenshot. Seems, that is something related to
chrome.runtime.sendMessage
chrome.runtime.sendMessage
. Maybe, someone is familiar with this error. Any idea?
1 Reply
tetec1
tetec1•2y ago
See my question, which seems related: https://discord.com/channels/946290204443025438/1114195473738244226 This seems to be a recent change from Chrome?
Want results from more Discord servers?
Add your server