Skip to content

Injecting AngularFireAuth to component triggers ChangeDetection continuously #1544

Closed

Description

@tomsgit

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

Activity

  1. davideast commented on Apr 3, 2018

    @davideast
    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.

  2. jamesdaniels commented on May 4, 2018

    @jamesdaniels
    Contributor

    Fixed in rc7

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions