Skip to content

Sentry Init failing in Chrome Extension Manifest V3 #4098

Closed
@abhishekops

Description

@abhishekops

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions