w3c / webextensions

Charter and administrivia for the WebExtensions Community Group (WECG)
Other
591 stars 54 forks source link

Native messaging connection from service worker #256

Open larry-xu opened 2 years ago

larry-xu commented 2 years ago

Chrome recently added support for service workers to run beyond the default 5 minute timeout if there is an open native messaging connection. See https://bugs.chromium.org/p/chromium/issues/detail?id=1189678

This is useful for extensions to receive messages from a connected native messaging host at any time. Otherwise, if the service worker terminates, then the connection is lost, and the native messaging host cannot send messages to the extension.

Can we standardize this functionality in MV3, so that it can be adopted by Firefox and Safari? And would this behavior differ at all between service workers and event pages?

bershanskiy commented 2 years ago

Please note that this is not really applicable to Firefox yet, since Firefox does not support service worker backgrounds yet. I'm not sure how Safari handles this case.

xeenon commented 2 years ago

Safari does not have a fixed timeout for service workers or background pages. As long as there is activity (events, messages, etc) the service worker will stay alive.

zombie commented 2 years ago

Firefox has the same approach to Safari, as long as extension has any activity, the native messaging connection would stay alive.