Skip to content
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

Firestore crashes after 10.7.1 -> 10.7.2 update in Expo/React Native #7962

Closed
Yonom opened this issue Jan 19, 2024 · 23 comments · Fixed by #7963
Closed

Firestore crashes after 10.7.1 -> 10.7.2 update in Expo/React Native #7962

Yonom opened this issue Jan 19, 2024 · 23 comments · Fixed by #7963

Comments

@Yonom
Copy link
Contributor

Yonom commented Jan 19, 2024

Operating System

iOS 17.2

Browser Version

React Native 0.73.2 / Hermes

Firebase SDK Version

10.7.2

Firebase SDK Product:

Firestore

Describe your project's tooling

React Native app initialized with Expo

Describe the problem

After upgrading to Firestore SDK 10.7.2, fetching documents from Firestore causes an error.

The crash occurs during the isSafari() call introduced in this commit: d7ace80#diff-d73aa623e0442e31903665f2d555bbf0e1a317db2009f526e8f7209ebf662917R66

This is because the isSafari() function from @firestore/utils accesses navigator.userAgent. On React Native, navigator.userAgent is undefined.

Steps and code to reproduce issue

@firebase/firestore: Firestore (10.7.2): INTERNAL UNHANDLED ERROR:  TypeError: Cannot read property 'includes' of undefined
    at isSafari
    at __PRIVATE_getDefaultRelativeIndexReadCostPerDocument
    at __PRIVATE_QueryEngine
    at createLocalStore
@Yonom Yonom added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Jan 19, 2024
@looptheloop88 looptheloop88 added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Jan 19, 2024
@dconeybe dconeybe self-assigned this Jan 19, 2024
@dconeybe
Copy link
Contributor

Thanks for identifying this crash and opening a PR with a fix (#7963)! My apologies for breaking your setup. I'll work with you to get your fix merged ASAP so it can be included in the next release.

@WhyGolfRyan
Copy link

WhyGolfRyan commented Jan 19, 2024

+1, Rollback to 10.7.1 fixed this issue for now.

DellaBitta pushed a commit that referenced this issue Jan 19, 2024
In #7929 some logic was added to Firestore to check for the browser being Safari. This new check for isSafari() unexpectedly threw an exception in React Native. This PR fixes the exception by explicitly checking for an object not being undefined before using it.

Fixes #7962
@LoranMaes
Copy link

I'm getting this error too and I've been stuck with it for the past day... I have to send this project to my teachers as my final and can't get it to work

@brunoqueiros
Copy link

@LoranMaes Remove node_modules and package-lock.json and rollback firebase to 10.7.1

@Yonom
Copy link
Contributor Author

Yonom commented Jan 20, 2024

Another temporary hacky fix would be to set userAgent :p

somewhere before calling firebase functions, e.g. in index.js:

window.navigator.userAgent = "ReactNative"; // javascript
// or
(window.navigator as any).userAgent = "ReactNative"; // typescript

@Peege151
Copy link

Peege151 commented Jan 25, 2024

I had this problem on 10.7.2 and rolled back and now I'm getting the same error with 10.7.1...

@firebase/firestore: Firestore (10.7.1): INTERNAL UNHANDLED ERROR:  TypeError: Cannot read property 'includes' of undefined
    at isSafari 

Not sure why I doubt there's actually I problem with 10.7.1... I start expo with --clear and it's clearly using 10.7.1.

@dconeybe
Copy link
Contributor

@Peege151 That's really odd that you're seeing the same crash on 10.7.1. That shouldn't be possible. Make sure you clear out your node_modules directory and any build caches that you have. Regardless, the fix to isSafari() will be included in the next release and should fix whatever problem you're seeing too.

@Yonom
Copy link
Contributor Author

Yonom commented Jan 25, 2024

@Peege151 make sure you've specified "10.7.1" and not "^10.7.1" or "~10.7.1" in your package.json. To be extra sure, check your yarn.lock file to see if the package actually resolves to "10.7.1"

@kaberaarthur
Copy link

I have a different problem; when I roll back to 10.7.1, I am getting the error "Error: Service firestore is not available". The code was running perfectly on version 10.0.0 but now am getting the "Error: Service firestore is not available" error with that one too. Now I am just really lost, here is my firebase package - "firebase": "10.7.1" - and here is my firebase config -

import firebase from "firebase/compat/app";
import "firebase/compat/auth";
import "firebase/compat/firestore";

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
...
};

// Initialize Firebase
const app = firebase.initializeApp(firebaseConfig);

// Use these for db & auth
const db = app.firestore();
const auth = firebase.auth();

export { auth, db };

@dev-arekusandoru
Copy link

@kaberaarthur getting the same issue. 10.7.2 gives me the error @firebase/firestore: Firestore (10.7.2): INTERNAL UNHANDLED ERROR: TypeError: Cannot read property 'includes' of undefined.

reverting back to 10.7.1 gives me the error Error: Service database is not available

@lasithalakmal
Copy link

Getting the same error.

@Yonom
Copy link
Contributor Author

Yonom commented Jan 26, 2024

The bug reported in this issue has been fixed (pending release). In the meantime, use my workaround or move away from 10.7.2.

@kaberaarthur @dev-arekusandoru @lasithalakmal If you're facing other issues with other versions, open a new issue for that. It's off topic here...

@arsotech
Copy link

Same issue. Workaround is not working either.

@mamadouD29
Copy link

mamadouD29 commented Jan 30, 2024

@dev-arekusandoru
@lasithalakmal
@Yonom
@arsotech
here is what I actually did to fix it when I rolled back.

  1. I Stopped my expo project
  2. In my package.json I removed the "firebase": "^10.7.2" line
  3. I deleted the package-lock.json and node_modules
  4. I install firebase 10.7.1 : npm install firebase@10.7.1 , it will install all your node_modules and package-lock.json
  5. I started my project back and all work pretty good like nothing happened. npx expo start -c

That is the solution right. Give a try

@Peege151
Copy link

In case anyone still has trouble... I had to additionally clear my yarn cache to get it to work again. I hope this helps someone!

@tansiner
Copy link

tansiner commented Jan 31, 2024

@dev-arekusandoru @lasithalakmal @Yonom @arsotech here is what I actually did to fix it when I rolled back.

1. I Stopped my expo project

2. In my package.json I removed the "firebase": "^10.7.2" line

3. I deleted the package-lock.json and node_modules

4. I install firebase 10.7.1 : npm install firebase@10.7.1 , it will install all your node_modules and package-lock.json

5. I started my project back  and all work pretty good like nothing happened. npx expo start -c

That is the solution right. Give a try

only deleted package-lock.json, removed "firebase": "^10.7.2" line from package.json and then installed earlier version which is firebase@10.7.1, it worked like a charm, thanks a lot, you are the man

@arsotech
Copy link

Yes that worked thank you

@SevostyanovAleksandr
Copy link

@dev-arekusandoru @lasithalakmal @Yonom @arsotech, помогло решение

@kaberaarthur
Copy link

I finally solved my issue, but I did that by creating a new project and moving all my code into it. I bet this is a rookie solution😂, but the app is now running ok on Firebase 10.7.1

@Yonom
Copy link
Contributor Author

Yonom commented Jan 31, 2024

@dconeybe counting everyone who interacted with this issue, this issue has affected 25+ devs and counting...

Would it be possible to accelerate a release cut? 😊

@KennethAduan
Copy link

I have a different problem; when I roll back to 10.7.1, I am getting the error "Error: Service firestore is not available". The code was running perfectly on version 10.0.0 but now am getting the "Error: Service firestore is not available" error with that one too. Now I am just really lost, here is my firebase package - "firebase": "10.7.1" - and here is my firebase config -

import firebase from "firebase/compat/app"; import "firebase/compat/auth"; import "firebase/compat/firestore";

// Your web app's Firebase configuration // For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { ... };

// Initialize Firebase const app = firebase.initializeApp(firebaseConfig);

// Use these for db & auth const db = app.firestore(); const auth = firebase.auth();

export { auth, db };

same Issue with this

@Yonom
Copy link
Contributor Author

Yonom commented Feb 2, 2024

A new firebase version was released, I guess you can now upgrade to that one for the fix: npm i firebase@10.8.0

@dconeybe
Copy link
Contributor

dconeybe commented Feb 6, 2024

Firebase JS SDK version 10.8.0 was released on February 1, 2024 with the fix for this bug (https://firebase.google.com/support/release-notes/js#version_1080_-_february_1_2024). Please upgrade to pick up the fix. Again, apologies for the inconvenience this bug caused.

@firebase firebase locked and limited conversation to collaborators Feb 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.