SafariExtensions
SafariExtensions copied to clipboard
port.onDisconnect is not fired when connection is broken
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.