-
Notifications
You must be signed in to change notification settings - Fork 927
Bug, firestore not working with react-native 0.71.3 #7115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like this is a regression of #2667 |
The culprit of the DOMException problem is #7019, which added these lines into firebase-js-sdk/packages/firestore/src/platform/browser/base64.ts Lines 25 to 29 in a8be6ed
I had no idea that using DOMException would be problematic. It looks the code should verify that firebase-js-sdk/packages/firestore/src/core/firestore_client.ts Lines 285 to 286 in a8be6ed
This bug was introduced in v9.17.2 (released March 2, 2023: https://firebase.google.com/support/release-notes/js#version_9172_-_march_2_2023) so downgrading to the previous version, 9.17.1, should fix this. I'll try to get the fix in the next release. As for the "Could not reach Cloud Firestore backend", enabling long polling is our typical initial recommendation when this problem is faced. Can you try out v9.17.1 and report back your experience? |
The strange thing is that Firestore implements special logic for react-native for base64 decoding that does not use So why is Firestore trying to use the browser logic in https://github.com/firebase/firebase-js-sdk/blob/a8be6ed527b4b5e8f46cc7badaa3a2171cf36327/packages/firestore/src/platform/browser/base64.ts to decode the base64 string? This sounds like a bundling/packaging issue. Even if I fix this @superphil0 Are you able to share your project so I can look at its structure? If not, could you share just the skeleton of the project, with the source code removed? |
Ok I've merged #7130 to fix the @superphil0 Please provide a project that we can use to reproduce and we'll see if we can figure out why the react-native-specific base64 decoding logic isn't being used. |
@superphil0, the app should be using the react-native bundle, but it appears to be using the browser bundle. Look for what could cause that. Or as @dconeybe suggested, provide a project reproducing the error so we can investigate further. |
I downgraded to 9.17.1, this fixes the DOMException, but unmasks atob. I created a reproduction repo and sent an invite to @dconeybe |
Thank you for the app, @superphil0. I've been able to reproduce and I've confirmed that, for some reason, your app is loading the |
@superphil0 I found this little suggestion about using metro with firebase: https://docs.expo.dev/guides/using-firebase/#configure-metro. I tried to do this with your app but it didn't seem to have any effects. Namely, after the line
I added a new line, becoming:
This didn't seem to have any effects though. Since I know nothing about react-native, I'm not sure there is much else I can do to help. The key is to figure out why your react-native project fails to import the react-native bundle from firestore. Can you dig into this a little? |
@superphil0, can you give me and @dwyfrequency access to the repro? |
@superphil0, there may be some information on this page that will help you fix the import. |
Hey, first, thank you for taking a look. I don't think the links you mentioned are relevant, since they are about expo, however we use react native. I will look at this next week as i am traveling currently. I think the app loading the wrong bundle might be the right direction. I inherited this project, so it's worth creating a react native project from scratch and trying to reproduce, however when i tried this i ran into a buggy version of react native init... @MarkDuckworth @dwyfrequency i added you |
I can't build your repo. But you might want to look at resolverMainFields. This field seems to specify which package entry points the metro bundler will use. In some cases, this will prefer the browser bundle. |
I still was unable to build the repo, likely issues on my machine. However, the repo indicates you are using the metro bundler. Can you test setting |
I can confirm this solves our issue with the firebase sdk. Thank you so much for your help |
Just wanted to leave an explanation for anyone else having this issue. This project's metro config added some custom options to
Metro's default resolver settings actually look at mainFields Their solution is just don't spread |
[REQUIRED] Describe your environment
Describe the problem
May be related to #6993
I started out on this journey by wanting to use the firebase SDK for our react-native App.
All I want to do is to read from firestore with the firebase js SDK.
First time I ran it, I got a weird time out, here are the logs with setLogLevel("debug")
If I run the same code on react in the browser on my Mac it works,
If I run my react code on the iOS simulator in the browser it also works.
if I run it in react native on iOS simulator the timeout appears.
If I try to add force long polling as suggested here, I get a different error: #6993 (comment)
if I build the iOS app with Hermes (https://hermesengine.dev/) disabled, same thing, doesn't work
if I build the iOS app with Hermes (https://hermesengine.dev/) disabled and debug through my chrome and add force long polling=> it works
Current workaround for me is:
use forceLongPolling as stated here: #6993 (comment)
and add:
Steps to reproduce:
Try run the following code on react-native with iOS simulator
Relevant Code:
Conclusion
Using firebase js SDK with React native currently only seems to work if you use "experimentalForceLongPolling"
However, this leads to another error, because atob and DOMException are not present in the global node runtime
I am guessing here, but either this is due to React-Native 0.71.3 or some changes to firebase js SDK
The text was updated successfully, but these errors were encountered: