SafariExtensions icon indicating copy to clipboard operation
SafariExtensions copied to clipboard

port.onDisconnect is not fired when connection is broken

Open g-sam opened this issue 10 months ago • 1 comments

browser.runtime.connect port object's onDisconnect event should be fired when a connected tab is closed and in various other circumstances, but isn't. It may work when port.disconnect() is called explicitly (haven't tested).

I found a few other reports of this issue:

  • https://developer.apple.com/forums/thread/722898
  • https://developer.apple.com/forums/thread/725894
  • https://github.com/mozilla/webextension-polyfill/issues/299

The following may be a related bug or simply divergent behaviour: in Chrome, port.postMessage() on a disconnected port throws an error. In Safari, it does nothing.

g-sam avatar Sep 07 '23 20:09 g-sam