Browser Extension MV3 Service Worker Debugging Runbook Builder

Troubleshoot Manifest V3 extension service worker lifecycle bugs, alarms, messaging, storage, permissions, and cross-browser behavior.

Prompt Template

You are a browser extension platform engineer creating a debugging runbook for Manifest V3 service worker issues.

Extension context: [extension purpose, target users, release stage]
Target browsers: [Chrome, Edge, Firefox, Safari, enterprise Chromium build]
Manifest version and permissions: [paste relevant manifest fields]
Background behavior: [alarms, messaging, context menus, network calls, storage, native messaging, OAuth]
Symptoms: [service worker stops, messages lost, alarms late, storage stale, permissions fail, review rejection]
Content scripts and pages: [content scripts, popup, options page, side panel, offscreen document]
State storage: [chrome.storage, IndexedDB, in-memory state, remote API, cache]
Recent changes: [MV2 migration, permission change, browser update, bundler change, API migration]
Build stack: [TypeScript, Vite, Webpack, Plasmo, WXT, custom]
Observability: [console logs, extension errors page, telemetry, support reports]
Constraints: [privacy, offline behavior, enterprise policy, store review rules]

Create:
1. Lifecycle map showing when the service worker starts, suspends, wakes, and loses in-memory state.
2. Reproduction matrix by browser, install/update state, permission state, tab state, and network state.
3. Debug checklist for alarms, runtime messaging, ports, storage reads, fetch calls, permissions, CSP, and bundler output.
4. Logging plan that avoids collecting private page data or auth tokens.
5. Likely root causes matched to symptoms, with concrete fixes and code patterns.
6. Automated and manual QA cases for updates, browser restart, idle timeout, popup close, content-script reconnect, and offline recovery.
7. Release monitoring plan and support intake fields for hard-to-reproduce extension bugs.
8. Escalation notes for browser-specific API behavior that needs official documentation verification.

Make the runbook practical for engineers debugging a real production extension, not a generic browser API summary.

Example Output

Symptom: Content Script Message Fails After Idle Period

Likely Cause

The service worker is suspended between events and the extension expects an in-memory session object to still exist.

Checks

- Inspect chrome://extensions service worker logs immediately after the failed message.

- Confirm the listener returns a Promise or calls sendResponse correctly for async work.

- Reload the tab and test after 30 seconds of idle time.

- Verify session state is read from chrome.storage or IndexedDB on each wake.

Fix Pattern

- Move volatile state to durable storage.

- Rehydrate state at the start of each event handler.

- Add a message retry path from the content script with a bounded timeout.

QA Matrix

| Scenario | Expected Result |

|---|---|

| Fresh install, permission accepted | First message wakes worker and succeeds |

| Browser restart | Alarms are recreated or verified |

| Extension update | Old storage schema migrates before handlers run |

| Offline mode | Request is queued or shows a clear recoverable error |

Tips for Best Results

  • 💡Assume the MV3 service worker can disappear between events and design tests around that fact.
  • 💡Capture browser version, extension version, install/update state, and permission state in every bug report.
  • 💡Avoid relying on popup state for background behavior because the popup is short-lived too.
  • 💡Keep logging privacy-safe: record event names and error classes, not page content.