---
title: "Record which service worker controlled the page | Proofline"
description: "A service worker can answer requests before they reach the network, so two browsers on the same URL can run different code."
url: https://proofline.sh/learn/service-worker-controlled-page/
---

[Learning center](/learn/)

# Record which service worker controlled the page

A service worker can answer requests before they reach the network, so two browsers on the same URL can run different code. A report that says "it fails on the dashboard" needs to say whether a worker controlled the page, and which version of it. The worker's script URL alone does not tell you the version.

Deployment failures The Proofline team November 22, 2026 4 min read

## Check whether a worker controlled the page

In the Console of the page that failed:

```
navigator.serviceWorker.controller?.scriptURL ?? 'no controlling worker'
```

`navigator.serviceWorker.controller` is the worker that controls this page, or `null`. [MDN: `ServiceWorkerContainer.controller`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller)

DevTools' **Application > Service workers** shows the same registration with its status, and also a **waiting** worker when a newer version is installed but not yet active. A waiting worker is common right after a deploy, and it means the page is still controlled by the old one. In the Network panel, responses the worker answered show **(ServiceWorker)** in the Size column. [Chrome DevTools: Debug service workers](https://developer.chrome.com/docs/devtools/progressive-web-apps)

## Record the version, not only the URL

Most sites register their worker at a fixed URL such as `/sw.js` and change its contents on each deploy. In our fixture we served `/sw.js` with `const V = 'v1'`, loaded the page, then changed the file to `v2`. Both versions reported the same `scriptURL`, `http://localhost:8790/sw.js`. After one reload, requests were still answered by the v1 worker.

To tell versions apart, record something the version changes:

-   If the worker exposes its build, ask it. A common pattern is a message handler that replies with a version string.
-   Otherwise, open the worker's source from **Application > Service workers** and copy its first lines or the build hash it contains.
-   Note the **Received** time shown for the active worker and whether a worker is waiting.

## Reproduce with and without the worker

A worker is part of the state the maintainer does not have. Two runs separate its role.

| Run | How | If the bug appears |
| --- | --- | --- |
| Without the worker | DevTools **Application > Service workers > Bypass for network**, or Playwright's `serviceWorkers: 'block'` context option | The bug is in the page or the server |
| With the reporter's worker version | In a fresh profile or context with no worker, serve that version's worker script from the build that shipped it, wait for `navigator.serviceWorker.ready`, reload, then confirm the controlling worker's version before reproducing | The bug is in the worker, or in how its cached responses meet the current page |

In our fixture, a context created with `serviceWorkers: 'block'` reported no controller and no registrations, and fetched `/v` from the network. Playwright also does not serve requests a service worker intercepts from a HAR file, and its documentation recommends blocking workers when [replaying recorded responses](/learn/har-replay-playwright/). [Playwright: Service workers option](https://playwright.dev/docs/api/class-browser#browser-new-context-option-service-workers)

Start from a profile with no worker because an existing worker keeps controlling the page while a newly registered one waits, unless the new one calls `skipWaiting()`. Our fixture showed the same thing in the other direction: after the script changed to v2, one reload still ran v1. Checking the version after registering is what makes the comparison valid.

A hard reload also bypasses the worker for that load, so a bug that vanishes on shift-reload and returns on a normal reload points at the worker. [Users still see the old version after a deploy](/learn/old-version-after-deploy/) covers the stale-version case in detail.

## Worked example: an offline page for an online user

This example is fictional. A user reports seeing the site's "You are offline" page while their connection works. The developer cannot reproduce it.

The user reports `navigator.serviceWorker.controller.scriptURL` as `/sw.js`, which tells the developer nothing new. The worker's source in **Application** starts with `// build 2026-11-03`, three weeks old, and a newer worker is **waiting**. The old worker's fetch handler fell back to the offline page on any response with status 500 or higher, including a 503 the API returned during a brief maintenance window. The developer registered the 2026-11-03 worker from that build's artifacts, forced the API to return 503, and the offline page appeared.

## Questions

### How does a user remove a stuck worker?

**Application > Service workers > Unregister**, or clearing the site's data, removes it. Capture the version first, because both destroy the evidence.

### Does the worker also cache responses?

Often, in Cache Storage, which **Application > Cache storage** lists. A worker version that reads an old cache entry can fail even when the worker itself is current. Record the cache names and the entry for the failing URL.

### Can a page be controlled on first load?

Not by default. A newly registered worker controls pages loaded after it activates, unless it calls `clients.claim()` to take control of open pages. Check for that call before concluding that a first visit cannot be affected.

Return to [reproducing what someone else saw](/learn/replay-browser-bug-report/) for the other layers a replay needs.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Users still see the old version after a deploy: find which cache answered](/learn/old-version-after-deploy/)
    
    Deployment failures The Proofline team November 20, 2026 5 min read
    
-   ### [Freeze the backend's answers with a recorded HAR](/learn/har-replay-playwright/)
    
    Network outages The Proofline team November 22, 2026 4 min read
