So I know there are a couple of standard service worker events and events in extension namespaces that my extension can react to and which can awake it. The question is when I use event listeners from 3rd party module (I'm using supabase specifically) will they wake the extension service worker? For example, in supabase we have onAuthStateChange
event which triggers every time an auth event happens (i.e. refresh token's expired). But if my service worker's asleep? Will it be fired/will that kind of event wake the service worker?
Supabase listener's declared in the global scope of the service worker, of course.
MCVE: background.ts
import supabase from 'API/client';
chrome.runtime.onInstalled.addListener((details: chrome.runtime.InstalledDetails) => {
if (details.reason === 'update') {
chrome.storage.local.set({ lastSyncSnapshot: null });
}
});
supabase.auth.onAuthStateChange((event: any, session: any) => {
if (event == 'TOKEN_REFRESHED') {
chrome.storage.local.set({ session: session });
}
});