Service workers and browser extensions

I quite enjoy a good bug hunt. Just yesterday, myself and Cassie were doing some bugfixing together. As always, the first step was to try to reproduce the problem and then isolate it. Which reminds me…

There’ve been a few occasions when I’ve been trying to debug service worker issues. The problem is rarely in reproducing the issue—it’s isolating the cause that can be frustrating. I try changing a bit of code here, and a bit of code there, in an attempt to zero in on the problem, butwith no luck. Before long, I’m tearing my hair out staring at code that appears to have nothing wrong with it.

And that’s when I remember: browser extensions.

I’m currently using Firefox as my browser, and I have extensions installed to stop tracking and surveillance (these technologies are usually referred to as “ad blockers”, but that’s a bit of a misnomer—the issue isn’t with the ads; it’s with the invasive tracking).

If you think about how a service worker does its magic, it’s as if it’s sitting in the browser, waiting to intercept any requests to a particular domain. It’s like the service worker is the first port of call for any requests the browser makes. But then you add a browser extension. The browser extension is also waiting to intercept certain network requests. Now the extension is the first port of call, and the service worker is relegated to be next in line.

This, apparently, can cause issues (presumably depending on how the browser extension has been coded). In some situations, network requests that should work just fine start to fail, executing the catch clauses of fetch statements in your service worker.

So if you’ve been trying to debug a service worker issue, and you can’t seem to figure out what the problem might be, it’s not necessarily an issue with your code, or even an issue with the browser.

From now on when I’m troubleshooting service worker quirks, I’m going to introduce a step zero, before I even start reproducing or isolating the bug. I’m going to ask myself, “Are there any browser extensions installed?”

I realise that sounds as basic as asking “Are you sure the computer is switched on?” but there’s nothing wrong with having a checklist of basic questions to ask before moving on to the more complicated task of debugging.

I’m going to make a checklist. Then I’m going to use it …every time.

Have you published a response to this? :

Responses

Related posts

Trust

I’m trying to understand why developers would trust third-party code more than a native browser feature.

When service workers met framesets

The browser equivalent of a Roman legion showing up in a space opera.

Apple’s attack on service workers

Kiss your service workers goodbye on iOS.

Move Fast and Don’t Break Things by Scott Jehl

A presentation at An Event Apart Seattle 2019.

Push without notifications

Making use of the real-time nature of push notifications without the annoying notification part.

Related links

as days pass by — Farmbound, or how I built an app in 2022

Stuart writes up the process up making a mobile game as a web app—not a native app. The Wordle effect reverberates.

It’s a web app. Works for everyone. And I thought it would be useful to explain why it is, why I think that’s the way to do things, and some of the interesting parts of building an app for everyone to play which is delivered over the web rather than via app stores and downloads.

Tagged with

Tagged with

Adding Response Metadata to Cache API Explainer by Aaron Gustafson and Jungkee Song

This is a great proposal that would make the Cache API even more powerful by adding metadata to cached items, like when it was cached, how big it is, and how many times it’s been retrieved.

Tagged with

Distinguishing cached vs. network HTML requests in a Service Worker | Trys Mudford

Less than 24 hours after I put the call out for a solution to this gnarly service worker challenge, Trys has come up with a solution.

Tagged with

Learning to unlearn – The Sea of Ideas

This is the real challenge for service workers:

For 30 years, we taught billions of humans that you need to be connected to the internet to consume the web via a browser! This means web users need to unlearn that web sites can’t be used offline.

Tagged with

Previously on this day

11 years ago I wrote Medieval times

Two German trips in two months.

15 years ago I wrote Talking the talk

Shooting the breeze in MP3s.

15 years ago I wrote Tears in the rain

All of these moments will be lost in time.

16 years ago I wrote </head>

A virtual conference is a real success.

17 years ago I wrote Voices that natter

Presentation: done. Conference: done.

20 years ago I wrote D'ye ken John Peel?

“Then here’s to John Peel with my? heart and soul”

22 years ago I wrote The Chimera Project

I’ve started surfing the web with a new browser. It’s called Chimera, a Mac OS X browser from Mozilla.

22 years ago I wrote Direct Marketing

Don Henley improves his street cred:

23 years ago I wrote Robohouse

Hmm… apparently I’m "Number 5, Goofy robot with life from Short Circuit".