I am wondering if anyone updated their codebase from V2 to V3 and how are they handling this considering background is not persistent anymore. I have some event listeners on clicked however because the service worker goes inactive after a short period of time this events are not getting triggered for me. Would love to hear some tips about handling this scenario. -Edit-
Please see below the code
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
"id": "log-selection",
"title": "Do Something",
"contexts": ["selection"],
});
chrome.contextMenus.onClicked.addListener(clickEventInfo);
});
function clickEventInfo(info, tab) {
if(info.menuItemId == "log-selection")
{
var dataInfo = {
name: info.selectionText
}
chrome.storage.local.set({dataInfo});
chrome.tabs.create({url:"section/some_page.html"});
}
}
So why is this working when the service worker is active however not doing anything when it goes inactive?