title: In a browser extension using manifest v3, how can I communicate between a content script and a devtools panel?
body: <p>I have a new browser extension I'm developing, which means that to make it publicly available on the Chrome Web Store, <a href="https://developer.chrome.com/docs/extensions/mv3/mv2-sunset/" rel="nofollow noreferrer">I must use manifest v3</a>. My extension is a DevTools extension, which means that to communicate with the content script, I have to use a background service worker to proxy the messages. Unfortunately, the <a href="https://developer.chrome.com/docs/extensions/mv3/devtools/" rel="nofollow noreferrer">docs on DevTools extensions</a> haven't been updated for manifest v3, and the <a href="https://developer.chrome.com/docs/extensions/mv3/devtools/#content-script-to-devtools" rel="nofollow noreferrer">technique they suggest</a> for messaging between the content script and the DevTools panel via the background script won't work if the background worker is terminated.</p>
  <p>I've seen some <a href="https://stackoverflow.com/a/66618269/374693">answers here</a> and <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=1152255#c21" rel="nofollow noreferrer">Chromium project issue report comments</a> suggest that the only available workaround is to reset the connection every five minutes. That seems hacky and unreliable. Is there a better mechanism for this, something more event based than an arbitrary timer?</p>