Deep Dive · 7 min read
Manifest V3 Service Workers: The Complete Mental Model
Service workers are the biggest change in MV3 — and the source of the most bugs. Here's how to think about them correctly.
Manifest V2 used long-lived background pages. Manifest V3 replaced them with short-lived service workers that wake up on events and shut down when idle. This single change breaks more first-time extensions than anything else.
What changes in practice
- No DOM access — service workers can't read or modify HTML directly.
- No in-memory state — the worker dies between events.
- All persistence must go through `chrome.storage` or IndexedDB.
- Timers (`setTimeout`, `setInterval`) don't survive worker shutdown — use `chrome.alarms`.
The correct mental model
Treat the service worker like a serverless function: it wakes up, handles one event, persists what it needs, and exits. Anything you keep in module-level variables will be gone next time. Anything you scheduled with `setTimeout` will not fire.
What ManifestGo does for you
Every generated extension uses `chrome.alarms` for scheduling and `chrome.storage.sync` for state — so your extension keeps working when the worker recycles.