Answer the question
In order to leave comments, you need to log in
How to fix chrome.runtime.sendMessage on extension update?
The function inside the script content starts to return an error when used.
Error:
Uncaught Error: Extension context invalidated.
It is possible to wrap it in a try, but the function remains broken, although the updated extension works fine and is ready to receive messages. Reloading the page is not a pretty solution (the user can type text on the site that will be lost).
Answer the question
In order to leave comments, you need to log in
It is necessary to unsubscribe from all events and call.
chrome.runtime.reload()
It is convenient to share via Port, It has an onDisconnected event, and that's where you can call reload ()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question