-
-
Couldn't load subscription status.
- Fork 1.7k
Closed
Labels
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/browser
SDK Version
8.21.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
No response
Steps to Reproduce
- Have a Manifest V3 browser (Chrome) extension
- Run
Sentry.initin the service worker (this used to be the "background script") - Observe an error
Expected Result
Sentry initializes without error.
Actual Result
An error is printed out:
[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/
Relevant PRs:
- feat(browser): Prevent initialization in browser extensions #10844
- fix(browser): Improve browser extension error message check #12146
The problem is with the condition WINDOW === WINDOW.top. In a service worker, WINDOW is resolved to globalThis and globalThis.top is undefined.
However, AFAIK it still applies that service worker's context is not shared, i.e. it should be fine to initialize Sentry there.
Metadata
Metadata
Assignees
Labels
Projects
Status
No status