[🐛] NativeFirebaseError constructor crashes on real-world input: Cannot read property 'code' of undefined 🔥
Issue
ERROR [Error: Uncaught (in promise, id: 6) TypeError: Cannot read property 'code' of undefined]
Call Stack constructor (node_modules/@react-native-firebase/app/dist/commonjs/internal/NativeFirebaseError.js:41:43) possiblePromise._catch$argument_0 (node_modules/@react-native-firebase/app/dist/commonjs/internal/registry/nativeModule.js:58:98) tryCallOne (address at (InternalBytecode.js:1:1180)
I keep getting the above error, whenever i start my app. Doesn't seem to break any funcitonality, but definitely would love to stop seeing it.
This issue only happens in Android.
Project Files
I didn't use any custom Native builds, pure Expo managed
Javascript
Nothing special in my code yet, simply initiating the firebaseApp
package.json:
{
...
"dependencies": {
"@aws-amplify/react-native": "^1.2.0",
"@aws-sdk/client-cognito-identity": "^3.577.0",
"@aws-sdk/client-s3": "^3.940.0",
"@babel/runtime": "^7.28.4",
"@gluestack-style/react": "^1.0.57",
"@gluestack-ui/config": "^1.1.20",
"@gluestack-ui/themed": "^1.1.73",
"@gorhom/bottom-sheet": "^5.2.6",
"@react-native-async-storage/async-storage": "^2.1.2",
"@react-native-community/netinfo": "^11.4.1",
"@react-native-firebase/app": "^23.8.2",
"@react-native-firebase/firestore": "^23.8.2",
"@react-native-picker/picker": "2.11.1",
"aws-amplify": "6",
"expo": "~54.0.31",
"expo-apple-authentication": "~8.0.7",
"expo-auth-session": "~7.0.8",
"expo-build-properties": "~1.0.10",
"expo-constants": "~18.0.10",
"expo-crypto": "~15.0.7",
"expo-dev-client": "~6.0.17",
"expo-image-manipulator": "~14.0.7",
"expo-image-picker": "~17.0.8",
"expo-linking": "~8.0.8",
"expo-location": "~19.0.7",
"expo-router": "~6.0.14",
"expo-secure-store": "~15.0.7",
"expo-splash-screen": "~31.0.10",
"expo-status-bar": "~3.0.8",
"expo-system-ui": "~6.0.8",
"expo-web-browser": "~15.0.9",
"jose": "^6.0.11",
"nativewind": "^4.2.1",
"nullthrows": "^1.1.1",
"react": "19.1.0",
"react-dom": "19.1.0",
"react-native": "0.81.5",
"react-native-gesture-handler": "~2.28.0",
"react-native-get-random-values": "^1.11.0",
"react-native-gifted-chat": "^3.2.3",
"react-native-keyboard-controller": "1.18.5",
"react-native-maps": "1.20.1",
"react-native-reanimated": "~4.1.1",
"react-native-safe-area-context": "~5.6.0",
"react-native-screens": "~4.16.0",
"react-native-svg": "15.12.1",
"react-native-vector-icons": "^10.3.0",
"react-native-web": "^0.21.0",
"react-native-worklets": "0.5.1",
"toastify-react-native": "^7.2.3",
"ts-node": "^10.9.1"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/plugin-transform-class-static-block": "^7.27.1",
"@testing-library/jest-dom": "^6.1.5",
"@tsconfig/react-native": "^3.0.2",
"@types/jest": "^29.5.10",
"@types/react": "~19.1.10",
"babel-preset-expo": "^54.0.6",
"eslint": "^8.57.0",
"eslint-config-universe": "^12.0.1",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.11",
"tailwindcss": "^3.4.17",
"typescript": "~5.9.2"
},
...
}
firebase.json for react-native-firebase v6:
# N/A
iOS
Click To Expand
ios/Podfile:
- [x] I'm not using Pods
- [] I'm using Pods and my Podfile looks like:
# N/A
AppDelegate.m:
// N/A
Android
Click To Expand
Have you converted to AndroidX?
- [ ] my application is an AndroidX application?
- [ ] I am using
android/gradle.settingsjetifier=truefor Android compatibility? - [ ] I am using the NPM package
jetifierfor react-native compatibility?
android/build.gradle:
react {
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
enableBundleCompression = (findProperty('android.enableBundleCompression') ?: false).toBoolean()
// Use Expo CLI to bundle the app, this ensures the Metro config
// works correctly with Expo projects.
cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
bundleCommand = "export:embed"
/* Autolinking */
autolinkLibrariesWithApp()
}
/**
* Set this to true in release builds to optimize the app using [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization).
*/
def enableMinifyInReleaseBuilds = (findProperty('android.enableMinifyInReleaseBuilds') ?: false).toBoolean()
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
android {
ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion
namespace 'com.guoshi.courtsmate'
defaultConfig {
applicationId 'com.guoshi.courtsmate'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0.0"
buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\""
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
def enableShrinkResources = findProperty('android.enableShrinkResourcesInReleaseBuilds') ?: 'false'
shrinkResources enableShrinkResources.toBoolean()
minifyEnabled enableMinifyInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
def enablePngCrunchInRelease = findProperty('android.enablePngCrunchInReleaseBuilds') ?: 'true'
crunchPngs enablePngCrunchInRelease.toBoolean()
}
}
packagingOptions {
jniLibs {
def enableLegacyPackaging = findProperty('expo.useLegacyPackaging') ?: 'false'
useLegacyPackaging enableLegacyPackaging.toBoolean()
}
}
androidResources {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
// Apply static values from `gradle.properties` to the `android.packagingOptions`
// Accepts values in comma delimited lists, example:
// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
// Split option: 'foo,bar' -> ['foo', 'bar']
def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
// Trim all elements in place.
for (i in 0..<options.size()) options[i] = options[i].trim();
// `[] - ""` is essentially `[""].filter(Boolean)` removing all empty strings.
options -= ""
if (options.length > 0) {
println "android.packagingOptions.$prop += $options ($options.length)"
// Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
options.each {
android.packagingOptions[prop] += it
}
}
}
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
if (isGifEnabled) {
// For animated gif support
implementation("com.facebook.fresco:animated-gif:${expoLibs.versions.fresco.get()}")
}
if (isWebpEnabled) {
// For webp support
implementation("com.facebook.fresco:webpsupport:${expoLibs.versions.fresco.get()}")
if (isWebpAnimatedEnabled) {
// Animated webp support
implementation("com.facebook.fresco:animated-webp:${expoLibs.versions.fresco.get()}")
}
}
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}
apply plugin: 'com.google.gms.google-services'
android/app/build.gradle:
// N/A
android/settings.gradle:
// N/A
MainApplication.java:
// N/A
AndroidManifest.xml:
<!-- N/A -->
Environment
Click To Expand
react-native info output:
OUTPUT GOES HERE
- Platform that you're experiencing the issue on:
- [ ] iOS
- [x ] Android
- [ ] 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:e.g. 23.8.2
Firebasemodule(s) you're using that has the issue:e.g. App, FireStore
- Are you using
TypeScript?Y&5.9.2
- 👉 Check out
React Native FirebaseandInvertaseon Twitter for updates on the library.
Interesting - thanks for reporting this - we've had the assumption that NativeError.userInfo is non-null for a long time and have never seen this, but we also had code in the NativeFirebaseError constructor that could handle the missing parts of userInfo already - just not userInfo missing entirely
I've posted up a PR that should fix this after review/merge/release
In the meantime if this is blocking you and you want to move ahead right now you can use the patch-package patchset from CI on the related PR, the app package patch is the one you'll want, relative to the 23.8.3 release
- #8843
Ya I am using my own OAuth flow and haven't started using Firebase AuthFlow yet, probably explains why the userInfo is missing.
This fix was shipped in 23.8.4