0

Does anybody know if there's an event listener which detects when a service worker is about to become inactive? Something like:

self.addEventListener('inactive', (event) =>
{
    // Random piece of code here
}

Reason being is that I want to save data to storage before it becomes inactive since the data gets removed once it becomes inactive.

  • 1
    There's no such event. You need to save the data immediately or after a very short delay aka *debounce*. See also [How to refactor global variables from MV2 to using chrome.storage in MV3 service worker?](https://stackoverflow.com/a/73090402) – wOxxOm Jan 23 '23 at 16:49

0 Answers0