Chrome Extension Extension Debugging Patterns — Best Practices

3 min read

Extension Debugging Patterns

This document covers common debugging patterns for Chrome extension development across different contexts.

Service Worker Debugging

Service workers run in the background and require special debugging approaches:

The popup context is短暂 and closes on blur:

Content Script Debugging

Content scripts run in the context of web pages:

Background Console (Service Worker)

The background/service worker console is separate from page consoles:

Message Passing Debugging

Debugging communication between extension contexts:

Storage Debugging

Inspect extension storage:

Permission Debugging

Verify active permissions at runtime:

chrome.permissions.getAll((permissions) => {
  console.log('Active permissions:', permissions);
});

This helps diagnose permission-related issues, especially with optional permissions.

Network Debugging

Extension network requests appear in different places:

Breakpoints Across Contexts

Each extension context has its own DevTools:

Common Errors

“Receiving end does not exist”

This typically means:

“Extension context invalidated”

This occurs after:

Re-establish connections after these events.

Useful Console Methods

Source Maps in Extensions

For bundled extensions:

Cross-References

Part of the Chrome Extension Guide by theluckystrike. Built at zovo.one.