Sentry Init failing in Chrome Extension Manifest V3
See original GitHub issue- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account
Package + Version
-
@sentry/browser -
@sentry/node -
raven-js -
raven-node(raven for node) - other:
Version:
6.13.3
Description
Apologies if this was asked previously. I’m trying to integrate Sentry into background scripts of Chrome Extension manifest V3. Sentry Initi fails with the following trace, upon digging into it, the exact line where it fails is https://imgur.com/a/UAGs5QR
Actual error trace:
Error in Sentry init TypeError: Cannot read properties of undefined (reading 'querySelector')
at y (background.bundle.js:118)
at g (background.bundle.js:118)
at e._createRouteTransaction (background.bundle.js:118)
at background.bundle.js:118
at a (background.bundle.js:127)
at e.setupOnce (background.bundle.js:118)
at l (background.bundle.js:79)
at background.bundle.js:79
at Array.forEach (<anonymous>)
at d (background.bundle.js:79)
at t.setupIntegrations (background.bundle.js:76)
at e.bindClient (background.bundle.js:103)
at o (background.bundle.js:94)
at Module.S (background.bundle.js:46)
at background.bundle.js:307
at background.bundle.js:307
at background.bundle.js:307
at background.bundle.js:307
This is expected to fail as the manifest V3 version of Chrome Extension background scripts don’t have access to DOM, and they are run as service workers, which explains the issue. I would like to know if there is a way to integrate Sentry where window/document objects aren’t present. Its really critical for us to integrate Sentry into the background scripts, as most of the important action happens there. Kindly assist if there is a solution or any workarounds for the problem. Thanks in advance.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:16 (3 by maintainers)
Top Related StackOverflow Question
@Vadorequest sorry about that. I created a follow-up issue with the bug you described instead of reopening this one, because the bug is a different one.
For the time being, I recommend chrome extension authors not to use the tracing package.
Hi, Raven.js is a very old version of our Sentry SDK and using it is discouraged! I just merged a PR that should fix this issue. We will have a release candidate for our upcoming v7 version soon. Please try it out and report back whether the fix resolved your issue!