Originally published on Extenify.
Chrome extension error logs only live on the machine where the error happened, which during development is yours and after a release is everyone else's. A global onerror handler in your Manifest V3 service worker looks like the fix, but it silently misses the errors that matter most. Here is where to look locally, what slips through, and a small pattern for collecting errors from real users.
Four places Chrome puts your errors
While developing, each part of an extension reports somewhere different:
| Part of the extension | Where to look |
|---|---|
| Manifest | Error dialog when loading the unpacked extension |
| Service worker | Errors button on chrome://extensions, or the console from "Inspect views: service worker" |
| Popup / options page | Errors button, or right-click the popup and choose Inspect |
| Content scripts | The host page's DevTools console, with your extension picked in the context dropdown |
Two gotchas: the Errors button only appears with Developer mode on, and it records runtime errors plus console.error and console.warn, never console.log. Content script errors usually show up in the page's console rather than on the Errors page. Edge offers the same views at edge://extensions.
None of this helps once the extension is on thousands of machines. Then your first error report tends to arrive as a one-star review.
The blind spot in global handlers
The natural move is self.addEventListener('error', ...) plus unhandledrejection in the service worker. The Extenify team tested this in Chromium 159 against six failure types:
-
throwinside asetTimeoutcallback: caught - A rejected promise nobody awaited: caught
- An async function that throws, called without
await: caught - A synchronous throw inside
chrome.runtime.onMessage: not caught (the sender'ssendMessagepromise rejects instead) - A throw inside
chrome.storage.onChanged: not caught - A content script's own throw: caught by the content script's
windowlistener
That gap is serious because most extension logic runs inside chrome.* event listeners. Chrome invokes them itself and handles synchronous exceptions, so they never reach self.onerror.
The good news is on the content script side: thanks to the isolated world, a content script's listener saw its own error but not the errors thrown by the website. Filtering by your own file URLs is still a sensible safety net.
Wrap listeners, then report
The fix is a small wrapper that reports and then rethrows, so Chrome's behavior is unchanged:
// Wrap any chrome.* listener so sync throws and rejections get reported. export function guard(label, fn) { return function (...args) { try { const out = fn.apply(this, args); if (out instanceof Promise) out.catch((err) => report(err, label)); return out; } catch (err) { report(err, label); throw err; // preserve Chrome's default handling } }; } chrome.storage.onChanged.addListener( guard('storage.onChanged', (changes) => { /* ... */ }) ); A sound report() function in the service worker should:
- Build a payload with the message, a trimmed stack, the extension version and the browser version.
- Replace your
chrome-extension://base URL in stacks and drop any line containing anhttp(s)://URL. - Fingerprint each error and send it once per worker lifetime, with a hard cap (the original uses 20) so a crash loop cannot flood your server.
- POST with
content-type: text/plainand swallow any fetch failure.
Step 4 has a nice side effect: a text/plain POST is a simple request, so it needs no CORS preflight. In the test it reached a server on a host the extension had no permission for. That means no new host permission and no new permission warning in your next update. You just can't read the response, which you don't need.
Content scripts shouldn't call your server directly. They forward their own errors to the worker with chrome.runtime.sendMessage, and the worker checks sender.id before reporting. Remember that a service worker can be stopped at any time, so a report fired right before shutdown may be lost. That is fine for error telemetry, not for data you can't afford to drop.
On the server, counting distinct where|message pairs per version per day answers the post-release question directly: did this version introduce something new?
If you already use Sentry
Sentry works, with one rule: don't call Sentry.init() in an extension. Sentry's own docs warn it pollutes global state shared with the host page. In the test with @sentry/browser 11.14.0, Sentry.init() in a content script logged a refusal and sent nothing.
Instead, create a manual BrowserClient and Scope, remove integrations that patch globals (such as GlobalHandlers and Breadcrumbs), set release to the manifest version, and add your own error listeners back. You still need to wrap chrome.* listeners. Also:
- Bundle everything. MV3 forbids remotely hosted code, so skip the Loader Script and
lazyLoadIntegration(). - Budget the size. The tested worker bundle came to about 87 KB minified, 31 KB gzipped.
- Check Inbound Filters if events don't show up; Sentry can drop errors it attributes to extensions.
Keep reports clean and disclosed
Send the message, a cleaned stack, and the extension and browser versions. Leave out page URLs, page content, form values and anything users type. Describe error reporting in your privacy policy and your store listing's privacy section, declare it in Firefox's data collection permissions, and consider an opt-out on your options page.
Key takeaways
- Check four places locally: the Errors button, service worker console, popup console and page console.
- Global
errorandunhandledrejectionhandlers miss throws insidechrome.*listeners, so wrap every listener. - A content script's error listener only sees your script's errors, not the site's.
- A
text/plainPOST needs no extra host permission. - With Sentry, use a manual client and scope, never
Sentry.init(), and bundle the SDK. - Tag every report with the version and compare error counts after each release.
The original article includes the complete reporter module, the content script forwarder and a full Sentry client setup in its guide to collecting Chrome extension error logs in Manifest V3. To put those errors next to store-side signals such as new versions, ratings and one-star reviews, see Extenify's extension tracking and alerts.
Which chrome.* listener has bitten you with an error you never saw in your logs?
