chrome browser extension(MV3) reconnect failure after disconnected
25 views
Skip to first unread message
pullagurla harisha
unread,
1:50 AM (8 hours ago) 1:50 AM
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions
Dear concerned, I have migrated my chrome browser extension from MV2 to MV3 Implementation: Implemented logic in content script to listen to Disconnect event and try reconnecting to background script(service worker) using chrome.runtime.connect() content-script uses chrome.runtime.connect() to start communication and postMessage() to continue communication with background script.. every 25seconds dummy message is sent as keepalive to keep service worker running
Issue: Chrome browser unloads the service worker and content-script reconnect(Recreating runtime port using chrome.runtime.connect() ) fails.. Tried reconnecting 5times every 3seconds
Please suggest if this is chrome browser expected behaviour.. If yes should content-script be reinjected to revive background script or are there any alternate ways to wakeup background script from content-script when reconnect fails.. any help is appreciated
woxxom
unread,
4:36 AM (5 hours ago) 4:36 AM
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions, pullagurla harisha
A backgrounded tab's timers may be paused by the browser and only fire once in a minute, so the preferred method is calling any asynchronous chrome API in the service worker itself as noted in the official documentation, but are you sure you need to keep the background script running and if so, why?