Menu

1 / 5

Chrome Extension Service Worker: 4 Rules to Survive Shutdown

DEV Community: javascript·ExtensionBooster·about 8 hours ago
#teQr5nhY
#devtojavascript#devto#dev#chrome#worker
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.