Urgent.News

What's breaking now, across thousands of outlets.

Tech

Debugging Service Workers in Firefox: DevTools, about:debugging, and Common Issues

Service workers are a critical web platform feature — they enable offline capabilities, push notifications, and background sync. Firefox has full service worker support. Here's how to work with them in Firefox DevTools. What Service Workers Do A service worker is a JavaScript file that runs in the background, separate from the page. It can: Intercept network requests and serve cached responses…

Service workers are essential web platform features enabling offline capabilities, push notifications, and background sync. Firefox offers comprehensive support for these functionalities. To work with service workers in Firefox, use Firefox DevTools and the about:debugging page. Service workers run in the background independently of web pages and can intercept network requests, handle push notifications, and pre-cache assets.

The service worker lifecycle consists of four stages: registration, installation, activation, and fetch interception. When debugging service workers in Firefox, navigate to about:debugging#/runtime/this-firefox. Here, you'll find all registered service workers listed, along with their scope, status, and buttons for inspection, push notification testing, and unregistering.

Firefox DevTools allow you to inspect, push notification test, and unregister service workers. The Application panel within DevTools provides access to the service worker's manifest, registered workers, storage details, and the ability to send test push notifications. The Network tab in the service worker Inspect window displays all intercepted network requests, helping diagnose stale content issues.

To debug fetch interception, use the Network tab in the service worker Inspect window. This tab shows all network requests intercepted by the service worker, including cached responses and network requests. The Console in the service worker context allows you to execute code within the service worker's context, enabling you to check cache contents and test logic.

During development, ensure the service worker activates correctly by checking the Installation phase. A common issue is a stuck previous version preventing activation. In the Application panel or about:debugging, look for a Waiting service worker. This indicates the new version is installed but unable to activate until all pages using the old version are closed. Resolve this by clicking the skipWaiting button (if added) or unregistering and reloading the page.

Firefox requires HTTPS for service workers, except on localhost. During development, use the Update on reload option in the Application panel to force the service worker to update on every page reload. Common service worker issues in Firefox include incorrect scope, registration errors, and HTTPS requirements. Test offline behavior by checking the Offline option in the Application panel or by throttling the network in the Network panel to simulate slower-than-offline conditions.

Background sync and push notifications are supported in Firefox. For push notifications, use the Web Push protocol, as Firefox doesn't depend on Google Play Services like Chrome does on Android. The about:debugging page allows you to send test push events to your service worker using the Push button. Workbox, Google's service worker library, generates production-ready service workers that function correctly in Firefox.

Debug Workbox workers using the Inspect console, which shows Workbox's log output. Enable verbose logging in your Workbox config or via about:config settings. Keep in mind that Firefox's service worker tooling is mature and covers all the debugging scenarios you'll encounter in production PWA development.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Setting an env var above your imports does not run before them, and our integration test works anyway

The largest test file in PubTrivia is 543 lines, and it has no mocks in it. It calls the actual server actions a player's phone calls, and the actual engine the host's buttons and our WebSocket server…

  • Lines above imports do not run before imports in ES modules
  • Import declarations are hoisted, evaluated before module execution
  • Async function disabling WebSocket notifications returns early with warning

about:config Settings Worth Changing (and What Not to Touch)

about:config is Firefox's advanced settings panel — a flat key-value store for hundreds of internal preferences. Most users never touch it.

  • DNS over HTTPS (Forced Mode) enhances privacy by routing DNS queries through a trusted resolver
  • Sanitize History on Shutdown clears cookies and history when Firefox closes for enhanced privacy

More from Friday 16 October →