MV3 migration - Service worker going inactive with open messaging ports

295 views
Skip to first unread message

Patrick

unread,
Dec 4, 2021, 6:05:31 PM12/4/21
to Chromium Extensions
Hi, 
I'm trying to migrate our team's extension to MV3. It's a devpanel extension that keeps messaging ports open to communicate through background between the devpanel and a content script.

But it seems Chrome is shutting down the service worker after 5 minutes even though I have messaging ports open and in use. I found this bug about the 5 minute shutdown issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1152255

The devpanel code gets "Attempting to use a disconnected port" after the service worker goes inactive. The service worker stays inactive as well, so I have a dead / useless devpanel window. 

But according to the documentation at https://developer.chrome.com/docs/extensions/mv3/service_workers/ 
"the service worker won't unload until all visible views and all message ports are closed."

So why is the service worker unloading when there are open message ports? Is the 1-year-old chromium bug covering the fact that MV3 violates its own spec? Or is that bug just about extensions that don't have open messaging ports, and I'm dealing with something different?



wOxxOm

unread,
Dec 5, 2021, 9:11:34 AM12/5/21
to Chromium Extensions, Patrick
Short answer is that MV3 is inherently broken. Until this is fixed, you'll have to re-connect each open port before its 5 minutes elapse.

Shu

unread,
Dec 5, 2021, 9:20:25 AM12/5/21
to Chromium Extensions, wOxxOm, Patrick
I updated all my extensions to mv3 and I regret it. Sales dropped and a lot of reports that extensions stop working, even after restarting of browser, some users must reinstall it each day to make it work.
Some of customers still use old browsers which don't support mv3 but got updates, so they notice extension is not working and I receive refund requests or disputes. My refund request rate was 0.9% and now it's 3.5%. So, I suggest to keep mv2 until mv3 is completely fixed, probably in a year :/

Reply all
Reply to author
Forward
0 new messages