React-redux-firebase: bug(react-native-firebase): enabling presence option throws exception "Invalid Firebase Database path"

Created on 6 Sep 2017  路  17Comments  路  Source: prescottprue/react-redux-firebase

What is the current behaviour?
I setup react-redux-firebase along with react-native-firebase following the documentation. So far so good, but when I set the config option presence I get an error saying "Invalid Firebase Database path: //.info/ connected. Firebase Database paths must not contain '.', '#', '$', '[' or ']'"

When calling reactReduxFirebase I'm passing an instance of firebase initialised natively (no call to initializeApp)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.

  • Follow the installation steps
  • Make sure react-native-firebase is initialised natively
  • Enable presence option

What is the expected behavior?
Presence and profiles will be sync'd without issues.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

  • react-native: 0.47.2
  • react-redux-firebase: canary
  • redux-saga: 0.15.6
  • redux-thunk: 2.2.0
  • react-native-firebase: next
bug react-native

Most helpful comment

@christophervalles Hmm... that is interesting. Let me continue to debug with that in mind.

All 17 comments

@christophervalles It looks like it may be an issue with react-native-firebase not supporting the .info/connected path (which is how the JS SDK determines if it is online or not).

We should file an issue with them and see if there is another method we should be using or if they can support this path. In the meantime though, I will look into ways to catch the error and make it more clear.

Oh, I see. I will open a ticket on their side too then.

Feel free to close this one unless you want to left it open to track any changes you do in regards to catching the error.

Cheers

@prescottprue I haven't opened a ticket on their side yet but I was just checking on my side. If I execute the following code to retrieve the .info/connected path, it works without issues, I get true. Should this call not fail too if they didn't support it or am I missing something?

import firebase from 'react-native-firebase'

...

firebase.database().ref('.info/connected').on('value', snapshot => {
    console.tron.log(snapshot)
})

@christophervalles Hmm... that is interesting. Let me continue to debug with that in mind.

Hi, I'm having the same bug, any news about the debugging ?

The recent v2.0.0-beta.11 release uses firebase.database().ref('.info/connected') directly as @christophervalles mentioned works for him. I have not yet tested it on react-native, but will try to in the next week. If this didn't fix it (which it most likely won't), it might require a deeper dive.

@prescottprue

Are we supposed to use firebase.database().ref('.info/connected') or is it now possible to use presence in the config ?

@samuelbriole The goal is to have you be able to use the presence config.

Like I said though, I didn't actually test if the small change in react-native yet, all I did was make the internal call use firebase.database().ref('.info/connected') directly (instead of using both ref and child).

Going to test it out myself, reproduce, and confirm before closing the issue though.

Found another issue while testing this out where a few versions of react-native-firebase did not have setPriority on their version of firebase.database.ThenableReference. v2.0.0-beta.13 includes logic that handles these versions.

From there, for me, using the react-native-firebase example, I'm no longer seeing this issue.

If anyone is still seeing the issue with presence with react-native-firebase after updating to v2.0.0-beta.13, post and we can reopen.

Hello @prescottprue, thank you for this fix, now it seems to work on iOS, but I still have the same error on Android.

It could also be a problem with the react-native-firebase library. What do you think ?

@samuelbriole Yeah that may be it, especially if it works on iOS. What version of react-native-firebase are you using?

@prescottprue v3.0.6 (latest release)

@samuelbriole Did you open an issue with react-native-firebase? I am wondering how/why the iOS and Android interactions would be different. Are you sure you are doing a fresh build for Android?

Not sure there is much that can be done in react-redux-firebase for this at this point since it is platform dependent, so going to close for now. If there are any updates totally down to re-open it.

@prescottprue I have the same issue, I enabled presence system in my config and I get an error : Invalid Firebase Database path: //.info/ connected. Firebase Database paths must not contain '.', '#', '$', '[' or ']'

Also when I call this resource by hand, I have no errors, like in this comment, so that's not an issue with react-native-firebase I think?

I am using
[email protected]
[email protected]

Hi! I have the same issue with Android and react-native-firebase. @pkamilp @samuelbriole how have you solve this?

@gsanguinetti Since this appears to only be an issue on Android and not IOS the guess has been that the error is within react-native-firebase - especially since this functionality is based on the firebase docs on connection state

We could maybe have a workaround to not enable this on Android in react-redux-firebase, but that doesn't feel right since we still don't know exactly what is going on. @gsanguinetti have you tried with the web SDK directly instead of react-native-firebase?

Hi @prescottprue. Yes, using the web sdk everything works fine. As you said, it seems to be a react-native-firebase bug, happening only in Android. I think one workaround to avoid this bug is not to use the connection state approach and to use a custom node for logging presence as react-native-firebase mentions.

But, Last Wednesday Firebase presented the "Online Presence Extension" at Firebase Summit, which is currently in alpha state. It may be that this extension becomes the future of this feature.

Was this page helpful?
0 / 5 - 0 ratings