You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Installing or updating the extension triggers chrome.runtime.onInstalled and ServiceWorkerRegistration.active
Reloading an unpacked extension (as opposed to toggle on/off), also fires the chrome.runtime.onInstalled, (I haven't been able to confirm on published extension but I anticipate the same)
Toggling on/off the extension results in only the ServiceWorkerRegistration.active event.
If you only intend to use this for true "installs" then you probably want to switch to onInstalled, however I think the more common requirement is actually to inject content scripts whenever the extension installs or reloads in such a way that the extension expects that the content scripts are loaded to matched pages and reachable (or can reach the background service). In which case you probably want ServiceWorkerRegistration.active to be the main triggering event.
The text was updated successfully, but these errors were encountered:
After digging through the code in webext-events, I see you're relying on session storage, which seems to work great, though the lifetime of session storage is poorly documented to describe this behaviour.
Anyways, I'll just leave this for your consideration then, you can potentially drop the storage requirement for ManifestV3 using the ServiceWorkerRegistration.active event, i.e.
self.addEventListener("activate",(event)=>{// effectively the same as onExtensionStart});
If it already exists, that would be great. But no one mentioned it in this thread so it might not match the expected behavior for extensions either. Please report it here for verification:
(thanks for the module, unfortunately I wrote this logic myself before I found this one, so thought I'd share my findings)
Per https://developer.chrome.com/docs/extensions/develop/concepts/service-workers/lifecycle, and after manual testing (Chrome 129 I think), I have found that onStartup doesn't fire when you expect as its bound to session startup not extension startup.
After some research I found that
If you only intend to use this for true "installs" then you probably want to switch to onInstalled, however I think the more common requirement is actually to inject content scripts whenever the extension installs or reloads in such a way that the extension expects that the content scripts are loaded to matched pages and reachable (or can reach the background service). In which case you probably want ServiceWorkerRegistration.active to be the main triggering event.
The text was updated successfully, but these errors were encountered: