Skip to content
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

[database][js] Reject promise instead of resolving an error object #867

Merged
merged 1 commit into from
Mar 9, 2018
Merged

[database][js] Reject promise instead of resolving an error object #867

merged 1 commit into from
Mar 9, 2018

Conversation

simonbengtsson
Copy link
Contributor

Currently ref.once() don't reject properly when a firebase call fails. This pull request fixes this and allows developers to properly handle those cases.

It could probably easiest be demonstrated by disallowing a path in in the database rules and than try a query like this:

firebase.database()
    .ref(`not/allowed/path`)
    .once('value')
    .then(snap => {
      console.log(snap instanceof Error); // true
      console.log(snap.val); // undefined (because it is not a snapshot...)
    })
    .catch(err => {
      // Never called, but is expected to be called
    });

This pull request aline with the behavior of the firebase web sdk.

@Salakar Salakar merged commit 44e005b into invertase:master Mar 9, 2018
@chrisbianca
Copy link
Contributor

Great spot!

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

Successfully merging this pull request may close these issues.

3 participants