Description
Operating System
Android 12, Android 13, iOS 18.3.1,...
Environment (if applicable)
React Native 0.71.14
Firebase SDK Version
11.0.2
Firebase SDK Product(s)
Firestore
Project Tooling
React native app
Detailed Problem Description
We migrated to firebase-js-sdk
from invertase/react-native-firebase
as this implements the TOTP MFA. However, after switching we got a lot of such logs in Sentry.
In the breadcrumbs we either see that the error is preceded by:
@firebase/firestore:,
Firestore (11.0.2): INTERNAL UNHANDLED ERROR: ,
RangeError: Maximum call stack size exceeded (native stack depth)
or:
@firebase/firestore:,
Firestore (11.0.2): INTERNAL UNHANDLED ERROR: ,
ReferenceError: Property 'TextEncoder' doesn't exist at __PRIVATE_newTextEncoder
And immediately after the app crashes.
The error occurs in various places in our code base such as on setDoc
and unsubscribe
from onSnapshot
, all of which we've catched, however it also occurs in native code which crashes the app. We noticed it only occurs in cases where there is poor network connectivity: All logs have some sort of WebChannelConnection error:
@firebase/firestore: Firestore (11.0.2): WebChannelConnection RPC 'Listen' stream 0x36232fef transport errored: [object Object]
The error occurs on all sorts of devices and versions, and both iOS and Android. There not really a trend there.
Steps and code to reproduce issue
We have found one reproduction scenario that works in 90% of the cases:
- User has update and read access to a specific document
- User turns off network connectivity
- User edits fields inside the document. This is cached and will be written when network connectivity is restored.
- Remove the document from firestore.
- User cannot write new document, only updates -> crash.
In some cases, we still do get the expected behaviour, which is a permission error being thrown. But is it inconsistent and flakey. This flow did work in react-native-firebase
.
I have also tried:
- To call
disableNetwork
andenableNetwork
when network connectivity changes - Upgrade firebase to latest version
- Downgrade firebase to 10.6.0
- Messed around with
experimentalForceLongPolling
andlocalCache
withpersistentLocalCache
to no avail.