Chrome will not start a Manifest V3 extension's background service worker
Fix it fast
Most common cause, 1 of 3The 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.
// 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();
}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.
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.
chrome://extensionsThen find the line you see in this list and open its fix:
- 1The worker uses window, document, localStorage or XMLHttpRequest
The entry after the status line is a ReferenceError naming one of those globals - 2The script uses import, but the manifest does not mark it as a module
The entry after the status line is a SyntaxError about an import statement, or the code calls import() at runtime - 3A top-level listener names an event that does not exist
The 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.
grep -nE "\b(window|document|localStorage|XMLHttpRequest)\b" service-worker.jsFix
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.
// 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.
chrome://extensionsConfirmed by developer.chrome.com
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.
grep -nE "^import |import\(" service-worker.jsFix
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.
{
"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).
chrome://extensionsConfirmed by developer.chrome.com
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.
grep -n "addListener" service-worker.jsFix
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.
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.
chrome://extensionsConfirmed by developer.chrome.com
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.