I have a problem with well known chrome extension issue - 'Uncaught Error: Extension context invalidated.'. Of course I saw the post 'Chrome extension content script re-injection after upgrade or install'. I'm trying to implement the solution but with some problems with onDisconnect part:
port = chrome.runtime.connect();
port.onDisconnect.addListener(reconnectToExtension);
The problem is that onDisconnect is triggered not only when user, for example, reload extension (from extension dashboard), but also when he reloads the tab with f5. I can't, for example, use window.location.reload when extension is disconnected to clean content_script DOM, because each reloads the tab will execute onDisconnect again. Is it a proper behavior?
Btw all 'solution' context_script code is working like infinite loop connectToExtension -> reconnectToExtension.
Unfortunately, I can't show the code. The code based on angular (background part) and typical js (content script part).