Skip to content

BaseClient._hooks are deleted when initializing @sentry/ember in Chrome #7640

Closed
@dagroe

Description

@dagroe

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.

@sentry/ember

SDK Version

7.45.0

Framework Version

Ember 7.45.0

Link to Sentry event

No response

SDK Setup

Partially set via environment.js:

    ENV['@sentry/ember'] = {
      sentry: {
        dsn: process.env.SENTRY_DSN,
        release: `${process.env.SENTRY_PROJECT_SLUG}@${process.env.REVISION}`,
        environment: process.env.SENTRY_ENVIRONMENT,

        tracesSampleRate: 1.0,
        browserTracingOptions: {
          tracingOrigins: [
            'localhost',
            'OUR_DOMAIN',
            'OUR_OTHER_DOMAIN'
          ],
        },
      },
    };

then initialized with additional config (has to be set this way since tunnel depends on some deploy specific settings that are not available in environment.js):

export function startSentry() {
  Sentry.init({
    // config.sentry is loaded automatically by init from ENV, we only need to set tunnel manually
    tunnel: tunnel,
    replaysSessionSampleRate: 0.0,
    replaysOnErrorSampleRate: 1.0,
    integrations: [
      new Sentry.Replay({
        // Additional SDK configuration goes in here, for example:
        maskAllText: true,
        blockAllMedia: true,
      }),
    ]
  });
}

startSentry is called in app.ts:

if (config.environment !== 'test') {
  startSentry();
}

export default class App extends Application {
  modulePrefix = config.modulePrefix;
  Resolver = Resolver;
}

loadInitializers(App, config.modulePrefix);

Steps to Reproduce

Sample project is here: https://github.com/dagroe/sentry-ember-chrome-bug

  • Put valid DSN in config/environment.js
  • install dependencies yarn install
  • run app ember serve
  • click "trigger error" button

Expected Result

After triggering an error, Session Replay data is sent to Sentry in Firefox and Chrome

Actual Result

After triggering an error, Session Replay data is sent to Sentry in Firefox but not in Chrome.

Sentry.init() is called twice in this setup. Once explicitly in app.js and a second time via instrumentForPerformance initializer in @sentry/ember/instance0initializers/sentry-performance.js.

In Firefox these two calls seem to happen before hooks are registered in the client. The afterSendEvent hook is then correctly registered.

In Chrome hooks seem to be registered after the first init() but before the second init(). The _hooks on client are thus reset to {} by the second init().

Metadata

Metadata

Assignees

Labels

Package: emberIssues related to the Sentry Ember SDK

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions