Skip to content

FIRESTORE (11.0.2) INTERNAL ASSERTION FAILED: Unexpected state #8791

Closed
@hoongtong

Description

@hoongtong

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:

  1. User has update and read access to a specific document
  2. User turns off network connectivity
  3. User edits fields inside the document. This is cached and will be written when network connectivity is restored.
  4. Remove the document from firestore.
  5. 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 and enableNetwork when network connectivity changes
  • Upgrade firebase to latest version
  • Downgrade firebase to 10.6.0
  • Messed around with experimentalForceLongPolling and localCache with persistentLocalCache
    to no avail.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions