Originally published on ExtensionLaunch .
Your Chrome extension service worker works perfectly while you test it, then silently drops state, misses events or "forgets" a timer once real users have it. That is not a Chrome bug: in Manifest V3 the background script is built to stop and restart, and your code has to expect it. Here are the shutdown rules and four habits that keep an extension working through them.
"Service worker (inactive)" is not an error
On chrome://extensions you will often see service worker (inactive) next to your extension. It only means the worker is stopped right now.
Chrome starts the worker when something it listens for happens (a toolbar click, a message, an alarm) and stops it again when things go quiet.…