fny
fny

Reputation: 33517

Firebase Not Running Callbacks As Expected

I have a Firebase DB with a { hello: 'world'} at its root. Whenever I try to read hello's value in Node, the callback isn't executed unless I modify the value from within the Node process.

Here's the once call:

let callback = (snapshot) => {
  console.log('The value is ', snapshot.val());
};

db.ref('hello').once('value', callback);

At this point I'd expect the callback to run and print "The value is world" printed... but nothing happens. Now say I use on instead of once. Even if I modify the value from the Firebase web console or another Node process, the callback still isn't called! The strange thing is all of this code works as expected in a browser with the same library version (v3.0.2).

The only way I've managed to execute the callback is by modifying the value directly from the same Node process.

db.ref('hello').once('value', callback);
db.ref('test').set('moon');

// => 'The value is moon.'

I've created a repository with test scripts to help replicate an debug the issue.

Upvotes: 3

Views: 303

Answers (1)

fny
fny

Reputation: 33517

It turns out this is a known issue affecting certain accounts, and the Firebase team is working on it!

Upvotes: 2

Related Questions