You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, AFAIK it still applies that service worker's context is not shared
Right, this is what we need to confirm. The serviceWorker's globalThis cannot be the same "instance" as window in the page. If they're not the same, Sentry.init along with global integratinos can be safely called.
Do you know if there's a unique property on the globalThis object of the service worker we can use to identify it?
while I don't consider myself to be an expert in the service workers domain, I can observe that globalThis is an instance of ServiceWorkerGlobalScope on which you can find a serviceWorker property. I suppose we could check for the existence of that.
Hey @ddomonkos I relaxed this check a bit in general in #13156 so that global scopes that are not the window global scope are generally exempted. For now I think this should fix your issue as well without special casing service workers. We'll merge this soon and include it in the next release.
Is there an existing issue for this?
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
Sentry.init
in the service worker (this used to be the "background script")Expected Result
Sentry initializes without error.
Actual Result
An error is printed out:
Relevant PRs:
The problem is with the condition
WINDOW === WINDOW.top
. In a service worker,WINDOW
is resolved toglobalThis
andglobalThis.top
isundefined
.However, AFAIK it still applies that service worker's context is not shared, i.e. it should be fine to initialize Sentry there.
The text was updated successfully, but these errors were encountered: