Angular change detection triggered by Sentry

Hi,
I am using Sentry within Angular application, lately, I notice that Angular change detection is running in an endless loop !!! every few milliseconds.
Seems like that Sentry place a setInterval which triggered the change detection, I don’t know why it does it but if it does it, it must be outside of ngZone.

Did someone notice that? any solution?
I tried to put the initialization of Sentry outside of ngZone but it didn’t solve the problem.

Niro.

1 Like

If you insert console.log(), please check this Issue:

Sentry constantly triggering change detection in Angular2+ application. · Issue #1800 · getsentry/sentry-javascript https://github.com/getsentry/sentry-javascript/issues/1800

Thanks for your answer.
Can you explain why console log will trigger change detection?

Hi, I have encountered this issue as well.

Here is a stacktrace of my console.log call:

push…/node_modules/@sentry/hub/dist/scope.js.Scope.notifyScopeListeners @ scope.js:43
push…/node_modules/@sentry/hub/dist/scope.js.Scope.addBreadcrumb @ scope.js:185
push…/node_modules/@sentry/core/dist/baseclient.js.BaseClient.addBreadcrumb @ baseclient.js:180
push…/node_modules/@sentry/hub/dist/hub.js.Hub.invokeClient @ hub.js:49
push…/node_modules/@sentry/hub/dist/hub.js.Hub.addBreadcrumb @ hub.js:224
push…/node_modules/@sentry/browser/dist/index.js.Breadcrumbs.addBreadcrumb @ index.js:3948
(anonymous) @ index.js:3665

The function notifyScopeListeners() from the scope.js file will eventually call the setTimeout() function, which then triggers another change detection cycle and then it ends in the infinite loop.