-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular Integration Issue - console.log calls cause Change detection to run #1883
Comments
The Angular side of this issue was closed as
|
Edit: I have to revise the statement above, the issue we faced did not occur due to console.log and the custom wrapping. We had an issue in our application that caused angulars change detection to be retriggered in an endless loop. Applying a best practice (writing the result into a property of the component instead of calling the service directly inside the template) fixed the issue for us. |
@omares Your issue might have been related to this other ticket of mine: angular/angular#27804 |
same issue, does not only happens for lifecyle methods but also for getters. There is any plan for this to be addressed? |
I'll need to find some time to dig into angular zone package to see why/how it happens. In the meantime, if console.log breadcrumbs are not crucial, they can be separately disabled with: Sentry.init({
// ...
integrations: [new Sentry.Integrations.Breadcrumbs({ console: false })]
// ...
}) |
Adding this causes an infinite loop when calling console.error
console.error triggers CD to run so we get in a loop if a template has an error. |
Closing the issue as a part of large repository cleanup, due to it being inactive and/or outdated. There's a large chance that this issue has been solved by 113be3a |
Related issue found. Re-opening, because the author closed it and it's definitely still an issue.
Package + Version
@sentry/browser
@sentry/node
raven-js
raven-node
(raven for node)Version:
Description
Using Sentry in an Angular project will cause Angular's change detection to fire any time
console.log
is called. This is because of Sentry's breadcrumb feature, which logs whatever was logged to the console, and how that interacts withzone.js
.I do not understand all of the mechanics behind it, but
zone.js
triggers change detection after the code to add a breadcrumb exits. An easy way to prevent the problem would be to wrapconsole.log
statement torunOutsideAngular
, which preventszone.js
from running change detection. However, the only two ways of doing would be either wrapping every call toconsole.log
(which would be very unwieldy and not-obvious) or override the globalconsole.log
function with a different function that calls the original function outside of Angular.I'm not entirely certain what can be done on Sentry's side to prevent the problem, as any solution would likely be very Angular-specific, in a package meant to be used with a variety of different frameworks. As such, I'm opening issues both here and against the Angular repo.
Edit: angular/angular#28647
Demo repro: https://github.com/ibedard16/sentry-recursion-demo
Instructions on how to run it are in the readme.
The text was updated successfully, but these errors were encountered: