Two MV3 errors you hit right after bumping manifest_version (and the fix)
You change "manifest_version": 2 to 3 and the extension breaks. Two errors show up a lot: Service worker registration failed chrome.browserAction is undefined Below is a small made-up teaching example (a tab counter), not a real project or client case. It is a partial migration, checked by reading the files only; it was not run in a browser . 1. The background page has to become a service worker…
Switching the manifest_version from 2 to 3 can cause two common errors when migrating a Chrome extension. One error is the service worker registration failing, and the second is the chrome.browserAction being undefined.
In the background page, which used to be a service worker in MV2, it now needs to be declared as a service worker in MV3. The background property should only contain the service_worker field pointing to the background.js file.
The browser_action object has been renamed to action, and the chrome.browserAction object has become chrome.action. This renaming affects the code where these objects were used.
In the case of state management, it's important not to keep state in a global variable. In MV2, the count variable was stored in memory and lost when the service worker stopped. Instead, the refresh function now awaits chrome.tabs.query({}) to get the tab count and sets the badge text accordingly using await chrome.action.setBadgeText({text: String(tabs.length)}).
Several other changes are required for a successful migration, including updating the background scripts, toolbar API, state management, callbacks, and startup listeners. It is recommended to thoroughly review the official Chrome MV3 migration guide before proceeding with the migration.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.