0

I'm creating an chrome extension that adds a contextMenu when the user select some text and do right click and adds an option to do some stuff with that text on that moment I need to send the selected text from the background.js to the content script to show in a model.

This works well but if I refresh the extension on the extensions page then I go the the page and select the text I get an exception

Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.

I think that when I refresh the extension the connection between the background.js and the content.js is lost, how can I prevent this without need to refresh the tab.

I think this problem will also happen if the extension is updated, probably will break all connection between the chrome.tabs.sendMessage from the background.js and the chrome.runtime.onMessage.addListener from the content script

Any tips?

0 Answers0