Sentry Init failing in Chrome Extension Manifest V3

See original GitHub issue

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
lforstcommented, Jun 21, 2022

@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.

2reactions
lforstcommented, May 24, 2022

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Import Sentry as module to the Chrome extension (manifest v3)
@wOxxOm In that case, i receive error Error: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'chrome-extension://***/ ...
Read more >
Adding Sentry Error Tracking to a Chrome Extension
Adding Sentry Error Tracking to a Chrome Extension · 1. Create a file in your chrome extension's root directory called sentry.js · 2....
Read more >
Sentry in chrome extension
Hi! We are trying to switch to sentry right now in our google chrome extension, but we hit the wall right now. We...
Read more >
MV3 service worker broken after auto-update - Google Groups
The extension is rendered completely useless; you can't even inspect the service worker at chrome://extensions/. No error is shown, and a browser(or ...
Read more >
Error Tracking in Chrome Extensions
Let's start by creating a new example extension with 3 files: manifest.json , index.html , and scripts.js . ... It's important to note...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found