Skip to content

Injecting AngularFireAuth to component triggers ChangeDetection continuously #1544

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

Closed
tomsgit opened this issue Apr 3, 2018 · 2 comments
Closed

Comments

@tomsgit
Copy link

tomsgit commented Apr 3, 2018

Version info

Angular: 5.2.0

Firebase: 4.12.1

AngularFire: 5.0.0-rc.6

Other (e.g. Ionic/Cordova, Node, browser, operating system): Windows 10, Google Chrome 65,npm: '5.6.0', node: '8.9.1'

How to reproduce these conditions

  1. Inject AngularFireAuth into the AppComponent.
  2. Create get method for a property. Log a message to console in the method.
  3. Refer the property in the template using {{}}
  4. View the application in chrome, observe console using developer tools

The log message in the get method is printed continuously as if in a loop. This behavior disappears if the constructor injection of AngularFireAuth is removed.

Failing test unit, Plunkr, or JSFiddle demonstrating the problem

https://embed.plnkr.co/S3cm7hpJImTtaTSa9Om0/

Steps to set up and reproduce
Create new Angular app. Add AngularFire2 and Firebase modules.

Sample data and security rules
None

None

Debug output

Please see attachment.

Expected behavior

The get method is called only once. The injected AngularFireAuth does not trigger ChangeDetection in Angular.

Actual behavior

The log message in the get method is printed continuously as if in a loop due to ChangeDetection being triggered.

localhost-1522757258645.log

@davideast
Copy link
Collaborator

This is a known issue and a problem with Zone.js rather than Firebase Authentication. Firebase Auth has a setInterval that deals with token refreshing in older browsers. Zone.js incorrectly picks up on this and forces change detection each second. We unfortunately have to account for this, but we do have a fix in master: #1454

We expect to do a nexttag release this week. When that is out I'll report back and you'll be able to give it a test.

@jamesdaniels
Copy link
Member

Fixed in rc7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants