🔥[v6][Android][FirebaseAuth] Gets error "undefined is not a function" in release when auth fails
When using a release build of Android, using signInWithEmailAndPassword or createUserWithEmailAndPassword with incorrect password or using email that already exists throws an error with a message undefined is not a function.
Expected behaviour is throwing Error message explaining the failure such as: [auth/wrong-password] The password is invalid or the user does not have a password.
Only happens in Android release mode. Using Hermes
- Platform that you're experiencing the issue on:
- [ ] iOS
- [x] Android with Hermes
- [ ] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [ ] Both
react-native-firebaseversion you're using that has this issue:-
"@react-native-firebase/app": "^0.1.3", -
"@react-native-firebase/auth": "^0.1.3", -
"@react-native-firebase/firestore": "^0.1.3",
-
- Are you using
TypeScript?N
Can you show us your full code usage please?
Yes,
I am not doing anything magic here just plain old email and password
async createUserWithEmailAndPassword({ email, password }) {
...
const res = await auth.createUserWithEmailAndPassword(email, password)
...
}
createUserWithEmailAndPassword({
email: emailValue,
password: passwordValue,
})
.catch(e => {
Alert.alert('Creating Account Failed', e.message)
})
When creating an account with email that already exists there will be alert saying undefined is not a function
Same for createUserWithEmailAndPassword just replace above code with createUserWithEmailAndPassword
The bug only happens in Android release mode. I do have hermes enabled but I do not know if this bug only happens in hermes.
The bug still exists after updating the version to 0.2.3
"@react-native-firebase/app": "^0.2.3",
"@react-native-firebase/auth": "^0.2.3",
Only android release...hmm. You can try figuring out which release transformation is causing it (java side via D8/R8 minify/shrink toolchain vs javascript) by pre-generating a release bundle for a debug-style java build and turning off your packager, or (the other direction) generating a debug bundle for a release style java build
here's how to control whether you get a bundle (even in debug) or not: https://github.com/facebook/react-native/issues/22234#issuecomment-504721069
And I believe in the 'project.ext.react = []' array you can set 'devDisabledInRelease: false' which can give you a debug javascript bundle with a release-mode java build
Might at least help see where the problem's coming from
I suspect some proguard rule and hypothesize the fault will be consistent in release java regardless of javascript build, and I further hypothesize that if you turn off shrink/minify in your java release build it'll work, but it's a weak hunch, I'm not certain about it at all, it's just the direction I'd troubleshoot first.
Interestingly, the test project doesn't include the proguard annotations documented for the v5 version of this project - not documented for v6?, because it only tests a debug build - so it wouldn't point out problems in this area, if this is the root cause
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.
Still an issue
I do have hermes enabled but I do not know if this bug only happens in hermes.
I tested out Hermes, it doesn't work correctly with this library. I'd suggest disabling it for now until there is better support.
There's something more to the way the v6 modules handle Hermes.
I'm getting the same undefined is not a function error with the AdMob module, when a BannerAd should execute a onAdFailedToLoad callback, for example.
This leads to a crash only with Hermes builds.
@piuholo unfortunately as far as I know Hermes is not spec compliant and its still fairly new; code that should 'just work' sometimes just doesn't in Hermes, such as in this case.
We can maybe look at this post-v6 as I feel like we'd be chasing our tails a bit trying to make things work with Hermes in its current state; or we'd be happy to accept PRs.
If you could provide the stack trace of where it's failing in JS it might also help pinpoint the underlying issue with our code in Hermes.
@Ehesp seems like a doc point is in order - I almost wasted my time giving Hermes a test but read this today and now I'm glad to have not wasted it. I'll look at v5 docs to mention it but I usually don't PR anything for v6 since I don't test it locally
https://github.com/invertase/react-native-firebase-docs/pull/218
While Hermes might not be ready for production, upgrading to react-native version 0.61.X that bumbed Hermes to v0.2.1 seemed to fix the undefined is not a function crash I got with the previous version.
@piuholo interesting - are you able to successfully use Hermes with react-native-firebase and test through all your projects features etc? I suspect Hermes will mature rapidly and be viable soon - I'm watching it - so I'm curious. Thanks
@mikehardy I have a beta release running that uses the v6 Admob and Analytics modules from react-native-firebase with Hermes, and it seems that at least those modules seem to be working fine.
@piuholo AdMob is setup differently that the other modules as it uses React Views rather than an API. Either way, the advice at the moment is to not use Hermes - we need to investigate into why it causes issues, but this library is one of the largest React Native ones so there is a LOT we need to check/test/cover before we can say its ok to use Hermes