invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.64k stars 2.21k forks source link

Error with firestore query using where and onSnapshot #3341

Closed pierregoutheraud closed 4 years ago

pierregoutheraud commented 4 years ago

Issue

I recently upgraded from 6.2.0 to 6.4.0-rc0.

When using a where clause with onSnapshot I am getting this error :

ExceptionsManager.js:126 Exception '-[__NSArrayM length]: unrecognized selector sent to instance 0x600002ad8270' was thrown while invoking collectionOnSnapshot on target RNFBFirestoreCollectionModule with params (
    "[DEFAULT]",
    "users/Zh2uYlG8pCQxBNePLnLj20w9kxu2/invitations",
    collection,
        (
                {
            fieldPath =             (
                status
            );
            operator = EQUAL;
            value =             (
                7,
                2
            );
        }
    ),
        (
    ),
        {
    },
    0,
        {
    }
)
callstack: (
    0   CoreFoundation                      0x00007fff23c7127e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff513fbb20 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23c91fd4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x00007fff23c75c4c ___forwarding___ + 1436
    4   CoreFoundation                      0x00007fff23c77f78 _CF_forwarding_prep_0 + 120
    5   alike                               0x0000000104a4a49c _ZN8firebase9firestore4util10MakeStringEPK10__CFString + 44
    6   alike                               0x000000010473cbbc _ZN8firebase9firestore4util10MakeStringEP8NSString + 60
    7   alike                               0x00000001047d9734 _ZN12_GLOBAL__N_113MakeFieldPathEP8NSString + 52
    8   alike                               0x00000001047d9641 -[FIRQuery queryWithFilterOperator:field:value:] + 97
    9   alike                               0x00000001047d5bd9 -[FIRQuery queryWhereField:isEqualTo:] + 105
    10  alike                               0x0000000104cf3efe -[RNFBFirestoreQuery applyFilters] + 638
    11  alike                               0x0000000104cf3c3c -[RNFBFirestoreQuery buildQuery] + 44
    12  alike                               0x0000000104cf3b6a -[RNFBFirestoreQuery initWithModifiers:query:filters:orders:options:] + 378
    13  alike                               0x0000000104ced73d -[RNFBFirestoreCollectionModule collectionOnSnapshot::::::::] + 573
    14  CoreFoundation                      0x00007fff23c7820c __invoking___ + 140
    15  CoreFoundation                      0x00007fff23c753af -[NSInvocation invoke] + 319
    16  CoreFoundation                      0x00007fff23c75684 -[NSInvocation invokeWithTarget:] + 68
    17  alike                               0x0000000104e76672 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2658
    18  alike                               0x0000000104e7a7a7 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 791
    19  alike                               0x0000000104e7a2b3 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 131
    20  alike                               0x0000000104e7a229 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
    21  libdispatch.dylib                   0x00007fff5223e848 _dispatch_call_block_and_release + 12
    22  libdispatch.dylib                   0x00007fff5223f7b9 _dispatch_client_callout + 8
    23  libdispatch.dylib                   0x00007fff52245526 _dispatch_lane_serial_drain + 707
    24  libdispatch.dylib                   0x00007fff52245f5c _dispatch_lane_invoke + 388
    25  libdispatch.dylib                   0x00007fff5224fff9 _dispatch_workloop_worker_thread + 626
    26  libsystem_pthread.dylib             0x00007fff524636fc _pthread_wqthread + 290
    27  libsystem_pthread.dylib             0x00007fff52462827 start_wqthread + 15
)

Here is my javascript code :

    this.unsub = db
      .collection("users")
      .doc(getUserId())
      .collection("invitations")
      .where("status", "==", 2)
      .onSnapshot(invitationsQS => {
        console.log(invitationsQS.docs);
      });

If I remove the where line, it works. It used to work fine on 6.2.0.


Javascript

Click To Expand

#### `package.json`: ```json { "dependencies": { "@babel/plugin-proposal-class-properties": "^7.1.0", "@babel/plugin-proposal-decorators": "^7.1.6", "@babel/plugin-transform-flow-strip-types": "^7.1.6", "@ptomasroos/react-native-multi-slider": "^1.0.0", "@react-native-community/async-storage": "^1.6.2", "@react-native-community/geolocation": "^2.0.2", "@react-native-community/masked-view": "^0.1.7", "@react-native-firebase/app": "6.4.0-rc0", "@react-native-firebase/auth": "6.4.0-rc0", "@react-native-firebase/database": "6.4.0-rc0", "@react-native-firebase/firestore": "6.4.0-rc0", "@react-native-firebase/functions": "6.4.0-rc0", "@react-native-firebase/messaging": "6.4.0-rc0", "@react-native-firebase/storage": "6.4.0-rc0", "@react-navigation/bottom-tabs": "^5.2.2", "@react-navigation/compat": "^5.1.4", "@react-navigation/native": "^5.1.1", "@react-navigation/stack": "^5.2.3", "@sentry/react-native": "^1.3.3", "add": "^2.0.6", "adm-zip": "^0.4.13", "babel-plugin-transform-remove-console": "^6.9.4", "babel-preset-react-native-stage-0": "^1.0.1", "firebase": "^7.0.0", "i18n-js": "^3.5.1", "plist": "^3.0.1", "progress": "^2.0.0", "react": "16.9.0", "react-native": "0.61.1", "react-native-circular-progress": "^1.0.1", "react-native-deck-swiper": "^1.6.7", "react-native-device-info": "^3.1.4", "react-native-fbsdk": "^1.1.1", "react-native-flags": "^1.0.0", "react-native-gesture-handler": "^1.6.0", "react-native-iap": "^3.5.2", "react-native-image-crop-picker": "^0.28.0", "react-native-image-picker": "^1.1.0", "react-native-image-resizer": "^1.0.1", "react-native-input-scroll-view": "^1.7.4", "react-native-keyboard-spacer": "^0.4.1", "react-native-languages": "^3.0.1", "react-native-linear-gradient": "^2.5.6", "react-native-permissions": "^2.0.0", "react-native-rate": "^1.1.7", "react-native-reanimated": "^1.7.0", "react-native-safe-area-context": "^0.7.3", "react-native-safe-area-view": "^1.0.0", "react-native-screens": "^2.3.0", "react-native-sortable-grid": "https://github.com/ollija/react-native-sortable-grid.git", "react-native-spinkit": "^1.5.0", "react-native-splash-screen": "^3.2.0", "react-native-svg": "^9.9.9", "react-native-swiper": "1.6.0-rc.3", "react-native-vector-icons": "^6.6.0", "react-native-version-number": "^0.3.6", "react-native-view-overflow": "^0.0.4", "react-native-webview": "^7.4.3", "react-redux": "^7.1.1", "redux": "^4.0.1", "redux-logger": "^3.0.6", "redux-mock-store": "^1.5.3", "redux-persist": "^6.0.0", "redux-thunk": "^2.3.0", "scheduler": "0.14.0", "semver": "^6.1.1", "timeago.js": "3.0.0", "xcode": "^1.0.0", "yarn": "^1.19.0" }, "devDependencies": { "@babel/core": "^7.6.2", "@babel/runtime": "^7.6.2", "@react-native-community/eslint-config": "^0.0.5", "babel-jest": "^24.9.0", "babel-preset-react-native": "4.0.0", "eslint": "^6.4.0", "jest": "^24.9.0", "metro-react-native-babel-preset": "^0.56.0", "react-test-renderer": "16.9.0" }, "jest": { "preset": "react-native" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS 10.15.3 CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Memory: 271.43 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node Yarn: 1.21.1 - /usr/local/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 23, 25, 26, 27, 28 Build Tools: 27.0.3, 28.0.2, 28.0.3 System Images: android-27 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.1 AI-173.4819257 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.1 => 0.61.1 npmGlobalPackages: react-native-cli: 2.0.1 ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [x] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - 6.4.0-rc0 - **`Firebase` module(s) you're using that has the issue:** - firestore - **Are you using `TypeScript`?** - N


pierregoutheraud commented 4 years ago

Turns out, I did not update pods 🤦‍♂️