Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Next.js and React

Chrome will not start a Manifest V3 extension's background service worker

Your error

Service worker registration failed. Status code: 15.1 more line it can show

Fix it fast

Most common cause, 1 of 3

The worker uses window, document, localStorage or XMLHttpRequest

Swap each call for something a worker can use: the extension storage API instead of localStorage, fetch() instead of XMLHttpRequest, and an offscreen document for work that truly needs the DOM.

Fix
// before: localStorage.setItem('color', '#3aa757');
browser.storage.local.set({ color: '#3aa757' });

// before: const xhr = new XMLHttpRequest();
async function loadData() {
  const res = await fetch('https://example.com/data.json');
  return res.json();
}
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Service worker registration failed. Status code: 15 means Chrome loaded your Manifest V3 background script but it threw an exception during its first run, so registration stopped. The real error is the next line in the Errors log on chrome://extensions. Common triggers: window, document, localStorage or XMLHttpRequest in the worker, import without "type": "module", or a misspelled API event.

  • Applies to Chrome 158 stable (Manifest V3), Chrome 148 or later for the browser namespace
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Open the extensions page with Developer mode on, reload the extension and click its Errors button. In Chromium's source, status 15 is kErrorScriptEvaluateFailed, so the entry right after the registration message is the exception that broke the script. DevTools for the worker stays unavailable until registration succeeds, which makes this log the place to look.

Run this first
chrome://extensions

Then find the line you see in this list and open its fix:

  1. 1The worker uses window, document, localStorage or XMLHttpRequestThe entry after the status line is a ReferenceError naming one of those globals
  2. 2The script uses import, but the manifest does not mark it as a moduleThe entry after the status line is a SyntaxError about an import statement, or the code calls import() at runtime
  3. 3A top-level listener names an event that does not existThe entry after the status line reads Cannot read properties of undefined (reading 'addListener')

What does the error look like?

  • Service worker registration failed. Status code: 15.
  • Uncaught TypeError: Cannot read properties of undefined (reading 'addListener')

Cause 1 of 3

The worker uses window, document, localStorage or XMLHttpRequest

You seeThe entry after the status line is a ReferenceError naming one of those globals

Check

Status code 15 follows here because an extension service worker has no DOM and no window object. Code moved over from a Manifest V2 background page that touches document, window.localStorage or XMLHttpRequest at the top level throws as soon as Chrome evaluates the file.

Check
grep -nE "\b(window|document|localStorage|XMLHttpRequest)\b" service-worker.js

Fix

Swap each call for something a worker can use: the extension storage API instead of localStorage, fetch() instead of XMLHttpRequest, and an offscreen document for work that truly needs the DOM.

Fix
// before: localStorage.setItem('color', '#3aa757');
browser.storage.local.set({ color: '#3aa757' });

// before: const xhr = new XMLHttpRequest();
async function loadData() {
  const res = await fetch('https://example.com/data.json');
  return res.json();
}

Verify

Reload the extension. The Errors button stays grey, and a service worker link appears under Inspect views.

Verify
chrome://extensions

Confirmed by developer.chrome.com

Did this fix it?

Cause 2 of 3

The script uses import, but the manifest does not mark it as a module

You seeThe entry after the status line is a SyntaxError about an import statement, or the code calls import() at runtime

Check

Chrome runs the background file as a classic script unless the manifest's background block sets type to module, and a classic script cannot contain an import statement. Dynamic import() is not supported in extension service workers in either mode.

Check
grep -nE "^import |import\(" service-worker.js

Fix

Declare the worker as a module in manifest.json and use static import lines at the top of the file. Replace any import() call with a static import or with importScripts() in a classic worker.

Fix
{
  "manifest_version": 3,
  "background": {
    "service_worker": "service-worker.js",
    "type": "module"
  }
}

Verify

After a reload the worker registers, and code from the imported file runs (for example a console.log you add there shows in the worker's DevTools).

Verify
chrome://extensions

Confirmed by developer.chrome.com

Did this fix it?

Cause 3 of 3

A top-level listener names an event that does not exist

You seeThe entry after the status line reads Cannot read properties of undefined (reading 'addListener')

Check

Event names are case-sensitive. runtime.oninstalled is undefined, so calling addListener on it throws while the file is first evaluated, and Chrome reports the registration failure first with the TypeError right after it.

Check
grep -n "addListener" service-worker.js

Fix

Correct the event name to the exact spelling in the API reference, for example runtime.onInstalled. If that API's reference page lists a permission, make sure it is in the manifest's permissions array.

Fix
browser.runtime.onInstalled.addListener(() => {
  browser.storage.sync.set({ color: '#3aa757' });
});

Verify

Click Clear all in the Errors view, reload the extension, and no new error appears.

Verify
chrome://extensions

Confirmed by developer.chrome.com

Did this fix it?

How do I stop it coming back?

  • Put any code that needs the page DOM in an offscreen document or the popup from the start, so the worker file never mentions document or window.
  • Keep the manifest's background type in step with the file: module when it has import lines, classic when it uses importScripts().
  • Reload the unpacked extension and open its Errors view after every change to the background script, before testing any feature.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.