Zenitsu
unread,Feb 24, 2022, 5:34:13 PM2/24/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
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, salem...@gmail.com, Chromium Extensions, Zenitsu
thanks for your reply! because the file is a service worker I don't think I can have a component there, and my use case is to not reply on a popup or a content script to do the service-worker tasks
what I'm trying to do is the following
In my extension background.js (service worker) I want to do this:
- connect to WebSocket to get data updates
- reconnect to the Websocket when service-worker wake up
- I need to do these tasks while not relying on having a port open with the popup or a content script
- those are tasks to get data updates from a WebSocket and update the badge text and send notifications.
note: I'm using Chrome Alarms to wake up the service worker
it may sound weird that I have to reconnect every time the service worker wakes up considering chrome is shutting the service worker down like every 15s or less once I close the extensions dev tools (which makes me cry blood)
but it is better than sending xhr periodically using Chrome alarms, which would result in a lot more requests being sent to an API, so reconnecting to the websocket
do you/anyone reading this have any recommendations/thoughts?