lapcat / SafariExtensions

Resources for the development of Safari extensions
43 stars 3 forks source link

port.onDisconnect is not fired when connection is broken #40

Open g-sam opened 1 year ago

g-sam commented 1 year ago

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:

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.

xeenon commented 7 months ago

It would be good to retry this on Safari Technology Preview 192, which uses WebKit's version of Web Extensions. Ports specifically have been rewritten there, and an error is thrown if the port is disconnected. There are a couple tests for onDisconnect.