Open tungnnt opened 2 years ago
I've been experiencing issues with service worker ever since MV3 and can't seem no narrow it down. It seems that mostly whenever I make some changes (webpack does compilation) Service worker starts misbehaving and all message communication between SW and Popup stops working. I've tried disabling HotModuleReplacement Plugin but still after every change I need to reload extension around 1-3 times to get it working, which is extremely annoying since it often even stops working after a while without making any changes.
As far as I understand it's expected that SW can be killed (become inactive) at any time, but it should automatically wake up when content script or popup is sending message, which is not the case for me. I'm guessing maybe something goes wrong with the listeners, but can't seem to figure out a solution.
anyone figure this out?
Hello, I successfully create an chrome extension from your template. I use
chrome.tabs.sendMessage
from Popup to send message to Content script. Content script usechrome.runtime.onMessage.addListener
to listen event from Popup, then usechrome.runtime.sendMessage
to send message to Service worker (Background in your template). In Service worker, I also usechrome.runtime.onMessage.addListener
to listen message from Service worker. I install my extension for the first time into my browser and it runs perfectly. However, after I restart chrome, the extension stops working because Popup sends message to Content Script, Content Script sends message to Service worker but Service worker is inactive (in chrome://extension, it says: service worker (Inactive)). Please give some advices. Thanks in advance.