Skip to content

Sentry constantly triggering change detection in Angular2+ application. #1800

Description

@surajpoddar16

Hey, I installed the new unified Sentry SDK in my Angular 7 project, and everything was working as expected, after a few days I noticed that the application performance had reduced, I tried to debug it and found that when I initialise the Sentry SDK, angular starts running change detection at an interval of few ms and it doesn't stop. I think there might be some asynchronous event that is getting captured inside Angular zone. Below are the details to reproduce this issue.

Inside your app module add the following code

export class AppModule {
constructor(applicationRef: ApplicationRef) {
//Angular change detection is run inside applicationRef.tick
//method. We are overriding this to log whenever change detection
//happens.
const originalTick = applicationRef.tick;
applicationRef.tick = function() {
const before = performance.now();
originalTick.apply(this, arguments);
const after = performance.now();
console.log("CHANGE DETECTION:", after - before);
return originalTick;
}
//Initialise Sentry with your DSN
Sentry.init({
dsn: __YOUR_SENTRY_DSN__
});
}

You can check the logs before and after commenting Sentry init part.
This has a lot of impact on our application's performance.

Please note that this issue didn't occur in the deprecated raven-js library.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions