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

android updates not getting to firestore backend, cached responses provided instead #765

Closed callagga closed 6 years ago

callagga commented 6 years ago

Background: I'm successfully integrating to firestore via react-native-firebase for IOS. When now aiming to get Android working the app is displaying rows I add via subscribing to updates, however it is all local, and not correcting through to the firestore backend. I checked the documents returned and they have doc.metadata.fromCache = true, whereas when I run on IOS this is always false. On Android overall then the app works as if it's in offline mode and never connecting. Some "allow network connections" setting in Android I've missed?

Question - Any thoughts on this issues? How can I fault find re the traffic/integration between the firestore client cache and the firestore backend?

Extract of code associated up withdates:

function createListChannel() {
  return eventChannel((emit) => {
    // 1st Argument - subscriber function
    console.log('updatedListsSaga: List Updates being Requested');
    firebase.firestore().collection('todos').onSnapshot(
      // Known Error: https://github.com/invertase/react-native-firebase/issues/719
      { includeQueryMetadataChanges: true },
      // { includeMetadataChanges: false },
      (querySnapshot) => {
        const numCached = querySnapshot.docs.reduce((acc, curr) => acc + (curr.metadata.fromCache ? 1 : 0), 0);
        const numPending = querySnapshot.docs.reduce((acc, curr) => acc + (curr.metadata.hasPendingWrites ? 1 : 0), 0);
        const numChanged = querySnapshot.docChanges.length;
        console.log(`updatedListsSaga Callback: #Docs=${querySnapshot.size}, #Changes=${numChanged}, #Cached=${numCached}  #Pending=${numPending} `);
        const items = querySnapshot.docs.map(doc => ({
          id: doc.id,
          fromCache: doc.metadata.fromCache,
          hasPendingWrites: doc.metadata.hasPendingWrites,
          title: doc.data().title,
          selected: doc.data().selected,
        }));
        emit({ items, error: undefined });
      },
      (error) => {
        console.log('updatedListsSaga: Received error from onSnapshot list update');
        emit(null, error);
      },
    );
    // 2nd Argument - unsubscribe function
    const unsubscribe = () => {
      console.log('updatedListsSaga: TBC - Unsubscribe for listSagas.js');
    };
    return unsubscribe;
  });
}
export function* updatedListsSaga() {
  const updateChannel = createListChannel();
  while (true) {
    const { items, error } = yield take(updateChannel);
    // console.log('updatedListsSaga: Took Update from Channel. Items:');
    // console.log(pf(items));
    if (items == null) {
      console.log(`updatedListsSaga: Error in updatedListsSaga: ${error}`);
      yield put({ type: ActionTypes.GetListItemsRejected });
    } else {
      yield put({ type: ActionTypes.GetListItemsFulfilled, list: items });
    }
  }
}
callagga commented 6 years ago

still an issue and I've ensured:

(a) have the following (see below) in AndroidManifest.xml.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

(b) put in a "fetch" to prove/show the app is calling out to the network

Ehesp commented 6 years ago

is there anything coming through in the Android native logs?

callagga commented 6 years ago

do you mean just "react-native log-android" logs?

If I add one item after another I see (copy/paste):

updatedListsSaga Callback: #Docs=0, #Changes=1, #Cached=0  #Pending=0 
updatedListsSaga Callback: #Docs=1, #Changes=1, #Cached=1  #Pending=1 
updatedListsSaga Callback: #Docs=2, #Changes=1, #Cached=2  #Pending=2 
updatedListsSaga Callback: #Docs=3, #Changes=1, #Cached=3  #Pending=3 
updatedListsSaga Callback: #Docs=4, #Changes=1, #Cached=4  #Pending=4 
updatedListsSaga Callback: #Docs=5, #Changes=1, #Cached=5  #Pending=5 
updatedListsSaga Callback: #Docs=6, #Changes=1, #Cached=6  #Pending=6 
callagga commented 6 years ago

If I run up the code on IOS however I get this:

IOS Log:

updatedListsSaga Callback: #Docs=1, #Changes=1, #Cached=0  #Pending=1 
updatedListsSaga Callback: #Docs=2, #Changes=1, #Cached=0  #Pending=1 
updatedListsSaga Callback: #Docs=3, #Changes=1, #Cached=0  #Pending=1 
updatedListsSaga Callback: #Docs=4, #Changes=1, #Cached=0  #Pending=1 
updatedListsSaga Callback: #Docs=5, #Changes=1, #Cached=0  #Pending=1 
updatedListsSaga Callback: #Docs=6, #Changes=1, #Cached=0  #Pending=1 
Ehesp commented 6 years ago

If you open your project in Android Studio, it will give you the full device logs in the "Logcat" tab at the bottom. I'm not sure what log-andoid filters out!

callagga commented 6 years ago

oh ok - if I start the app, and then do a "reload" I see this:

The last entry seems suspicious:

01-19 21:28:12.965  8629  8629 D ReactNative: ReactInstanceManager.onReloadWithJSDebugger()
01-19 21:28:12.965  8629  8629 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
01-19 21:28:12.965  8629  8629 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
01-19 21:28:12.965  8629  8629 D ReactNative: ReactInstanceManager.tearDownReactContext()
01-19 21:28:12.969  8629  8629 D ReactNative: CatalystInstanceImpl.destroy() start
01-19 21:28:12.970  8629  8629 W unknown:ReactNative: Packager connection already open, nooping.
01-19 21:28:12.974  8629  8654 D ReactNative: CatalystInstanceImpl.destroy() end
01-19 21:28:13.016  8629  8728 D ReactNative: ReactInstanceManager.createReactContext()
01-19 21:28:13.017  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTGroupViewManager
01-19 21:28:13.017  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTGroupShadowNode
01-19 21:28:13.018  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTShapeViewManager
01-19 21:28:13.018  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTShapeShadowNode
01-19 21:28:13.019  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTTextViewManager
01-19 21:28:13.020  8629  8661 D EGL_emulation: eglMakeCurrent: 0xec3dc180: ver 2 0 (tinfo 0xedbd6380)
01-19 21:28:13.020  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTTextShadowNode
01-19 21:28:13.021  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.checkbox.ReactCheckBoxManager
01-19 21:28:13.024  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.uimanager.LayoutShadowNode
01-19 21:28:13.026  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.picker.ReactDialogPickerManager
01-19 21:28:13.026  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.drawer.ReactDrawerLayoutManager
01-19 21:28:13.027  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.picker.ReactDropdownPickerManager
01-19 21:28:13.028  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.scroll.ReactHorizontalScrollViewManager
01-19 21:28:13.028  8629  8661 D EGL_emulation: eglMakeCurrent: 0xec3dc180: ver 2 0 (tinfo 0xedbd6380)
01-19 21:28:13.029  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.scroll.ReactHorizontalScrollContainerViewManager
01-19 21:28:13.029  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.progressbar.ReactProgressBarViewManager
01-19 21:28:13.029  8629  8661 E Surface : getSlotFromBufferLocked: unknown buffer: 0xe0b2a500
01-19 21:28:13.029  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.progressbar.ProgressBarShadowNode
01-19 21:28:13.030  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.scroll.ReactScrollViewManager
01-19 21:28:13.030  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.slider.ReactSliderManager
01-19 21:28:13.031  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.slider.ReactSliderManager$ReactSliderShadowNode
01-19 21:28:13.031  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.switchview.ReactSwitchManager
01-19 21:28:13.031  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.switchview.ReactSwitchManager$ReactSwitchShadowNode
01-19 21:28:13.031  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.toolbar.ReactToolbarManager
01-19 21:28:13.032  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.webview.ReactWebViewManager
01-19 21:28:13.033  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.swiperefresh.SwipeRefreshLayoutManager
01-19 21:28:13.034  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTSurfaceViewManager
01-19 21:28:13.035  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTSurfaceViewShadowNode
01-19 21:28:13.035  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.frescosupport.FrescoBasedReactTextInlineImageViewManager
01-19 21:28:13.035  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.frescosupport.FrescoBasedReactTextInlineImageShadowNode
01-19 21:28:13.036  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.image.ReactImageManager
01-19 21:28:13.036  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.modal.ReactModalHostManager
01-19 21:28:13.037  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.modal.ModalHostShadowNode
01-19 21:28:13.037  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactRawTextManager
01-19 21:28:13.038  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactRawTextShadowNode
01-19 21:28:13.038  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.textinput.ReactTextInputManager
01-19 21:28:13.045  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.textinput.ReactTextInputShadowNode
01-19 21:28:13.051  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactTextViewManager
01-19 21:28:13.056  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactTextShadowNode
01-19 21:28:13.057  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.view.ReactViewManager
01-19 21:28:13.060  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.viewpager.ReactViewPagerManager
01-19 21:28:13.060  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactVirtualTextViewManager
01-19 21:28:13.061  8629  8728 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactVirtualTextShadowNode
01-19 21:28:13.064  8629  8728 D RNFirebaseAuth: RNFirebaseAuth:initialized
01-19 21:28:13.065  8629  8728 D ReactNative: Initializing React Xplat Bridge.
01-19 21:28:13.068  8629  8728 D ReactNative: Initializing React Xplat Bridge before initializeBridge
01-19 21:28:13.070  8629  8728 D ReactNative: Initializing React Xplat Bridge after initializeBridge
01-19 21:28:13.070  8629  8728 D ReactNative: CatalystInstanceImpl.runJSBundle()
01-19 21:28:13.071  8629  8733 D ReactNative: ReactInstanceManager.setupReactContext()
01-19 21:28:13.071  8629  8733 D ReactNative: CatalystInstanceImpl.initialize()
01-19 21:28:13.072  8629  8629 W unknown:ReactNative: Packager connection already open, nooping.
01-19 21:28:13.072  8629  8733 D ReactNative: ReactInstanceManager.attachRootViewToInstance()
01-19 21:28:13.784  1262  1320 D hwcomposer: hw_composer sent 3306 syncs in 60s
01-19 21:28:15.199  8629  8661 D EGL_emulation: eglMakeCurrent: 0xec3dc180: ver 2 0 (tinfo 0xedbd6380)
01-19 21:28:19.104  8629  8725 W unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketFailed",{"message":"failed to connect to /10.0.2.2 (port 8097) after 10000ms","id":12}])
callagga commented 6 years ago

PS I didn't seem to pick up an error subscribing to updates in my code (ie. firebase.firestore().collection('todos').onSnapshot) in the sense I didn't see any console output corresponding to where I try to catch an error here:

console.log('updatedListsSaga: Received error from onSnapshot list update');

Ehesp commented 6 years ago

Hmm, we don't actually have any tests for the onSnapshot with the full list of args. Have you tried it with the 4th onCompletion argument at all?

I'm wondering whether the internal logic isn't handling your use case.

callagga commented 6 years ago

I put in onCompletion and it doesn't seem to hit this console.log line: That is:


    firebase.firestore().collection('todos').onSnapshot(
      // Known Error: https://github.com/invertase/react-native-firebase/issues/719
      { includeQueryMetadataChanges: true },
      // { includeMetadataChanges: false },
      (querySnapshot) => {
        const numCached = querySnapshot.docs.reduce((acc, curr) => acc + (curr.metadata.fromCache ? 1 : 0), 0);
        const numPending = querySnapshot.docs.reduce((acc, curr) => acc + (curr.metadata.hasPendingWrites ? 1 : 0), 0);
        const numChanged = querySnapshot.docChanges.length;
        console.log(`updatedListsSaga Callback: #Docs=${querySnapshot.size}, #Changes=${numChanged}, #Cached=${numCached}  #Pending=${numPending} `);
        const items = querySnapshot.docs.map(doc => ({
          id: doc.id,
          fromCache: doc.metadata.fromCache,
          hasPendingWrites: doc.metadata.hasPendingWrites,
          title: doc.data().title,
          selected: doc.data().selected,
        }));
        emit({ items, error: undefined });
      },
      (error) => {
        console.log('updatedListsSaga: Received error from onSnapshot list update');
        emit(null, error);
      },
      () => {
        console.log('updatedListsSaga: Hit OnCompletion re onSnapshot list update');
      },

    );

Also the logcat output when all I do is keep adding new rows is:


01-19 21:54:48.683  8629  8629 W unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["firestore_collection_sync_event",{"querySnapshot":{"metadata":{"hasPendingWrites":true,"fromCache":true},"documents":[{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/0IBB69o1480EnV0U43j5"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/o8UGhKYqkapMuHPbI81P"}],"changes":[{"oldIndex":-1,"newIndex":1,"document":{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},"type":"added"}]},"listenerId":"AiFTUlRd34saXVIO16Ix","path":"todos","appName":"[DEFAULT]"}])
01-19 21:54:48.684  8629  8629 W unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["firestore_collection_sync_event",{"querySnapshot":{"metadata":{"hasPendingWrites":true,"fromCache":true},"documents":[{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/0IBB69o1480EnV0U43j5"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/o8UGhKYqkapMuHPbI81P"}],"changes":[{"oldIndex":-1,"newIndex":1,"document":{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},"type":"added"}]},"listenerId":"sIqwv2Xae8g5JNBCYNtg","path":"todos","appName":"[DEFAULT]"}])
01-19 21:54:48.685  8629  8629 W unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["firestore_collection_sync_event",{"querySnapshot":{"metadata":{"hasPendingWrites":true,"fromCache":true},"documents":[{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/0IBB69o1480EnV0U43j5"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/o8UGhKYqkapMuHPbI81P"}],"changes":[{"oldIndex":-1,"newIndex":1,"document":{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},"type":"added"}]},"listenerId":"khk9A5edUsw9fccP62CF","path":"todos","appName":"[DEFAULT]"}])
01-19 21:54:48.686  8629  8629 W unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["firestore_collection_sync_event",{"querySnapshot":{"metadata":{"hasPendingWrites":true,"fromCache":true},"documents":[{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/0IBB69o1480EnV0U43j5"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/o8UGhKYqkapMuHPbI81P"}],"changes":[{"oldIndex":-1,"newIndex":1,"document":{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},"type":"added"}]},"listenerId":"sMwhqm9YJbYSOGVZSWgz","path":"todos","appName":"[DEFAULT]"}])
01-19 21:54:48.687  8629  8629 W unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["firestore_collection_sync_event",{"querySnapshot":{"metadata":{"hasPendingWrites":true,"fromCache":true},"documents":[{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/0IBB69o1480EnV0U43j5"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/o8UGhKYqkapMuHPbI81P"}],"changes":[{"oldIndex":-1,"newIndex":1,"document":{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},"type":"added"}]},"listenerId":"KW0xUPTxRFErQAYDESae","path":"todos","appName":"[DEFAULT]"}])
01-19 21:54:48.687  8629  8629 W unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["firestore_collection_sync_event",{"querySnapshot":{"metadata":{"hasPendingWrites":true,"fromCache":true},"documents":[{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/0IBB69o1480EnV0U43j5"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/o8UGhKYqkapMuHPbI81P"}],"changes":[{"oldIndex":-1,"newIndex":1,"document":{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},"type":"added"}]},"listenerId":"qsh2t2byIoZqpF0nhkRK","path":"todos","appName":"[DEFAULT]"}])
01-19 21:54:48.688  8629  8629 W unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["firestore_collection_sync_event",{"querySnapshot":{"metadata":{"hasPendingWrites":true,"fromCache":true},"documents":[{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/0IBB69o1480EnV0U43j5"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/o8UGhKYqkapMuHPbI81P"}],"changes":[{"oldIndex":-1,"newIndex":1,"document":{"metadata":{"hasPendingWrites":true,"fromCache":true},"data":{"selected":{"value":false,"type":"boolean"},"title":{"value":"1","type":"string"}},"path":"todos/fp8g24zEfEiTcocOapOG"},"type":"added"}]},"listenerId":"WQ8twBA9bzWayCTVbkE4","path":"todos","appName":"[DEFAULT]"}])
callagga commented 6 years ago

some update from firebase groups below

There's currently an issue in react-native that prevents Firestore from working properly on Android. See https://github.com/firebase/firebase-js-sdk/issues/283 and https://github.com/facebook/react-native/pull/17449.  As a workaround for now, you can probably add this code (before you initialize firebase) to work around the bug:

const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
  if (body === '') {
    originalSend.call(this);
  } else {
    originalSend.call(this, body);
  }
};
chrisbianca commented 6 years ago

@callagga this issue applies to the Firebase JS SDK, not the Android native SDK.

jurosh commented 6 years ago

@callagga thanks, that code made Firestore connection functional. (using JS SDK on Expo RN)

PatrickFelber commented 6 years ago

@callagga Worked for us as well! Thanks :)

mycob commented 6 years ago

@callagga thank you!

chrisbianca commented 6 years ago

Everything has gone a bit quiet on this. I'm going to assume that it was a firebase SDK issue which will have been addressed in one of the later versions.

We've also added explicit enable/disableNetwork controls to the upcoming v4 release which should give greater control over situations like this.