question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angularfire 2.3.0 incompatible with firebase 3.7.1

See original GitHub issue

Version info

Angular: 1.6.1

Firebase: 3.7.1

AngularFire: 2.3.0

Other (e.g. Node, browser, operating system) (if applicable): Chrome Version 56.0.2924.87 (64-bit)

Test case

https://plnkr.co/edit/kKHCbTgqVicuHUAHwigr?p=preview

Steps to reproduce

  1. Input your firebase credentials
  2. (optionally) set your DB rules to allow read/write anonymously for test purposes
  3. when the plunkr runs, the window should freeze.

Pausing the execution in dev tools will show you an infinite async loop that I’m describing at the end of this report.

Expected behavior

not freezing

Actual behavior

freezing

Some debugging info

When using 3.6.6 and stepping into the $add function. We can see that the firebase reference looks like this:

ref: U
  Nc: false
  catch: undefined
  database: (...)
  key: (...)
  m: ee
  parent: (...)
  path: L
  ref: (...)
  root: (...)
  then: undefined
  u: Te
  __proto__: X

When using 3.7.1 and stepping into the $add function. We can see that the firebase reference looks like this:

ref: T
  Nc: false
  catch: ()
  database: (...)
  key: (...)
  m: lg
  parent: (...)
  path: L
  ref: (...)
  root: (...)
  then: ()
  u: Sd
  __proto__: Y

Wee se that catch and then are functions. Which seems to lead to an endless async loop in angular ($q). Where the recursive function $$resolve keeps calling itself, from here: https://github.com/angular/angular.js/blob/03043839d5a540b02208001fe12e812dfde00a8e/src/ng/q.js#L426 and here: https://github.com/angular/angular.js/blob/03043839d5a540b02208001fe12e812dfde00a8e/src/ng/q.js#L439 because this: https://github.com/angular/angular.js/blob/03043839d5a540b02208001fe12e812dfde00a8e/src/ng/q.js#L424 keeps being true

That’s as far as I got 😃 I don’t understand how or why this is happening, but I believe I have pinned down where it happens and I’m able to reproduce it.

I haven’t found any other reports of this so I hope I’m not reposting 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

2reactions
jwngrcommented, Mar 21, 2017

@jshcrowthe and I have tracked down the underlying issue which was a recent change in the Firebase SDK which was introduced in 3.7.1. I was able to create the following repro which shows the issue without AngularFire at all:

var firebase = require("firebase");

var config = {
  databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
};

firebase.initializeApp(config);

var ref1 = firebase.database().ref("messages").push();
var ref2 = firebase.database().ref("messages").push("foo");

/*
ref1
  .then(function() {
    console.log("[ref1] All done!");
  })
  .catch(function(error) {
    console.log("[ref1] Error:", error);
  });
*/

ref2
  .then(function() {
    console.log("[ref2] All done!");
  })
  .catch(function(error) {
    console.log("[ref2] Error:", error);
  });

This script runs successfully as is (after you replace <DATABASE_NAME>) and outputs "[ref2] All done!". But if you uncomment the commented out block of code, the script will hang and not output anything. The problem is a recent change to push() when it does not contain a value. That returns a ThenableReference which is fulfilled with another ThenableReference, instead of a regular Reference, triggering an infinite loop of promise fulfillment. AngularFire runs into this issue on these lines.

We are putting together a fix which we will get out as soon as we can.

1reaction
jshcrowthecommented, Mar 29, 2017

Firebase 3.7.4 was just released that contains a fix for this issue! (See full release notes here: https://firebase.google.com/support/release-notes/js#3.7.4)

I have updated your plunk (https://plnkr.co/edit/HVu3tAVg1kMpNvYOGb3B?p=preview) and things seem to be working as intended.

For clarity’s sake an isolate example of the issue (no angular/angularfire) can be found here: http://jsbin.com/habeyed/9/edit?html,console

Thanks for your patience and let us know if there are any further issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angularfire 2.3.0 incompatible with firebase 3.7.1 #922 - GitHub
when the plunkr runs, the window should freeze. Pausing the execution in dev tools will show you an infinite async loop that I'm...
Read more >
Error @angular/fire build incorrectly extends interface
The types returned by 'data(...)' are incompatible between these types. Type 'T' is not assignable to type 'DocumentData'. 26 export interface ...
Read more >
firebase - UNPKG
The CDN for firebase. ... 2.2.8, 2.2.9, 2.3.0, 2.3.1 ... TYPE) {\n throw TypeError('Incompatible receiver, ' + TYPE + ' required');\n } return...
Read more >
could not resolve dependency: npm err! peer @angular/core ...
When I try to update @angular/cdk or other packages I usually get a message saying the dependencies are incompatible (see error block).
Read more >
angular/fire - npm
NgRx friendly API - Integrate with NgRx using AngularFire's action based APIs. Lazy-loading - AngularFire dynamically imports much of Firebase, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found