firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.8k stars 884 forks source link

auth/network-request-failed when debugging on react native #2652

Open shirlev-wix opened 4 years ago

shirlev-wix commented 4 years ago

[REQUIRED] Describe your environment

[REQUIRED] Describe the problem

Getting an error when running on debug mode on the simulator (both for ios and android)

code: "auth/network-request-failed"
message: "A network error (such as timeout, interrupted connection or unreachable host) has 
occurred."

I created a small react native app to reproduce the bug: https://github.com/shirlev-wix/firebase-bug

return Promise.resolve()
        .then(() => firebase.initializeApp(options, this.name))
        .then(app => app.auth().signInWithCustomToken(authKey)

Thanks!

rommelpe commented 4 years ago

Thanks for the report, @shirlev-wix. While I'm trying to replicate this, can you try using the latest version (7.8.2)? Most of these reports tend to be network related. If you can get network logs, that would be very helpful.

rommelpe commented 4 years ago

@shirlev-wix I'm trying to reproduce this issue but haven't been able to. Putting your working repro up on StackBlitz would be very helpful as we could fork it and might help you get it running. Thanks!

google-oss-bot commented 4 years ago

Hey @shirlev-wix. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

shirlev-wix commented 4 years ago

Hi, Upgrading firebase didn't help. I created a small react native app to reproduce the bug. https://github.com/shirlev-wix/firebase-bug

When debugging you can see the UI stays not connected.

shirlev-wix commented 4 years ago

Hi @rommelpe! Any updates regarding this one? It is really making our life harder when trying to debug things related to firebase.

kishansbs commented 4 years ago

same issue --

code: "auth/network-request-failed", message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred."

"firebase": "^7.13.2",
"react": "16.9.0",
"react-native": "0.61.5",
nyenye commented 4 years ago

Not sure is the same, but I get a an error saying I have no connection on my device on an Android Emulator, but making requests with i.e. unfetch library, work just fine.

edit: In my case it happens with await Firestore.collection('users').get()

berndartmueller commented 4 years ago

Our users experience the same auth/network-request-failed firebase auth issues since some time now. It mainly happens to Android Chrome users and the issue start immediately after/during using firebase.auth().signInAnonymously. (Note: I'm not using react, I simply use plain old Node.js SSR with vanilla js)

I'm also having a hard time reproducing the issue, I tried many real devices as well as devices on Browserstack. I'm just not getting this issue.

I already made sure that

Any ideas or any idea how I could reproduce it myself? Thanks a lot!

jefelewis commented 4 years ago

I'm receiving the same issue with React. I was testing logging in and it was returning a user object. 10 or so times later, it just stopped working and I have got the message Error: A network error (such as timeout, interrupted connection or unreachable host) has occurred. for the past 12 hours.

Possible ways to resolve? Is this possibly a limit issue? Should I delete node_modules and do a fresh install of the the npm packages? Should I downgrade the firebase library?

"firebase": "^7.15.1",
"react": "^16.13.1",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"redux-saga-firebase": "^0.15.0"
HassanAbass commented 4 years ago

I'm facing the same error when trying to use google/facebook signing with popup, used to work before and nothing change in the code.

//version
"firebase": "^7.15.5"

let provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(e => ...)
brloman commented 4 years ago

Im facing the same error using google to sign in with signInWithPopup. Works for some users just fine but fails for other users. //version "firebase": "^7.15.5"

frietkip commented 4 years ago

I am running into the same error using google to sign in to my web app build with next js and deployed on vercel. Both on local, development and production. image

"firebase": "^7.14.2",

Please advice

avolkovi commented 4 years ago

Folks-

Thanks for reporting this, does anyone have a trace for the endpoint and underlying error (like in https://github.com/firebase/firebase-js-sdk/issues/3081#issuecomment-631589480)? The Network Error you are seeing is a generic error we throw when the underlying fetch() call fails.

HassanAbass commented 4 years ago

In my case with signInWithPopup the pop up url (app-name/__/auth/...) was unreachable and no redirect to facebook/google happens, it worked again days later without changing anything.

google-oss-bot commented 4 years ago

Hey @shirlev-wix. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

shirlev-wix commented 4 years ago

What kind of information do you need? Like I wrote on March 6, here's a demo project that reproduce the bug: https://github.com/shirlev-wix/firebase-bug

obrunopolo commented 3 years ago

I'm having the same issue with a React Native Expo app. All of the sudden I cant make any development and I'm stuck with this unexpected error.

yzalvov commented 3 years ago

@obrunopolo , I faced with network problems on Android working with Expo too. I don't have a permanent solution, though two things work for me while developing:

I hope this will help you for development and there will be a fix from Firebase team soon.

Georgemburu commented 3 years ago

I had the same Error. I solved it by Turning on the my phones internet connection by connecting to wifi.

Solution Turn on your phone's internet connection.

obrunopolo commented 3 years ago

@Georgemburu that is not a "solution". Do you believe someone would come to GitHub and comment on this Issue just because the internet connection isn't on? I had this issue on a specific private wifi connection, all apps were working fine, except mine.

emad-ir commented 3 years ago

So I was having a similar issue where I was getting [Error: [auth/network-request-failed] A network error has occurred, please try again.] on and IOS phone whenever I tried to auth().signInWithPhoneNumber(phoneNumber)

And the reason for that was because the Date and Time on the phone was wrong 🤷🏻‍♂️

rosalyntan commented 3 years ago

Hi all, this issue is being tracked internally at b/171738114. It's on our radar to investigate, but unfortunately we don't have a timeline for this right now.

MittalShruti commented 3 years ago

I am getting the same error, while using google-auth in react, on chrome browser. The authentication was working fine just yesterday. I am using a button to call the authentication function.

<button id="login">LOG IN</button>

avinashg-wal commented 3 years ago

It's November 2020, firebase login was working fine until yesterday, but now it does not work anymore. It always throws auth/network-request-failed error 👎

Screenshot 2020-11-02 at 1 40 41 PM
avinashg-wal commented 3 years ago

@google-oss-bot @shirlev-wix @Georgemburu

rameshvishnoi90904 commented 3 years ago

Any updates on this? some of my users started facing this issue, and are stuck out of app.

viv3kk commented 3 years ago

In my case with signInWithPopup the pop up url (app-name/__/auth/...) was unreachable and no redirect to facebook/google happens, it worked again days later without changing anything.

We are also facing this issue. On one particular occasion, we tried to debug the cause for 4 hours and then it was back to working. Another in most of the cases, changing the network connection (from broadband to mobile hotspot) helped get around this issue.

Recently I faced this issue twice on consecutive Mondays.

viv3kk commented 3 years ago

@Georgemburu that is not a "solution". Do you believe someone would come to GitHub and comment on this Issue just because the internet connection isn't on? I had this issue on a specific private wifi connection, all apps were working fine, except mine.

@obrunopolo Yes I agree this is not the issue. Although this is mostly not an issue related to network and firebase should get some help if changing networks solves this issue. I have also switched between 2 working connection, but it works on one network and fails on another.

rahul-96 commented 3 years ago

Same error/issue. Suddenly. Did not change anything. It was working a while back perfectly. Pasting my error in the log which I'm getting from the code

firebase.auth().signInWithPopup(provider).then(function (result) {
...
}).catch(function (error) {
      // Handle Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
      // The email of the user's account used.
      var email = error.email;
      // The firebase.auth.AuthCredential type that was used.
      var credential = error.credential;
      console.log(error); //This it the error being consoled.
    }); 

The error in console:

_> u {code: "auth/network-request-failed", message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred.", a: null}

a: null code: "auth/network-request-failed" message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred." proto: Error constructor: ƒ u(a, b, c) Za: constructor: ƒ Error() message: "" name: "Error" toString: ƒ toString() proto: Object arguments: (...) caller: (...) length: 3 name: "u" prototype: Error {constructor: ƒ, v: ƒ, toJSON: ƒ} proto: ƒ ()

toJSON: ƒ d() v: ƒ () proto: Object_

Please help. Is there nay development on this issue? The error is coming in production. Users are not able to login. Please help. Thank you so much in advance.

viv3kk commented 3 years ago

Same error/issue. Suddenly. Did not change anything. It was working a while back perfectly. Pasting my error in the log which I'm getting from the code

firebase.auth().signInWithPopup(provider).then(function (result) {
...
}).catch(function (error) {
      // Handle Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
      // The email of the user's account used.
      var email = error.email;
      // The firebase.auth.AuthCredential type that was used.
      var credential = error.credential;
      console.log(error); //This it the error being consoled.
    }); 

The error in console:

_> u {code: "auth/network-request-failed", message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred.", a: null}

a: null code: "auth/network-request-failed" message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred." proto: Error constructor: ƒ u(a, b, c) Za: constructor: ƒ Error() message: "" name: "Error" toString: ƒ toString() proto: Object arguments: (...) caller: (...) length: 3 name: "u" prototype: Error {constructor: ƒ, v: ƒ, toJSON: ƒ} proto: ƒ ()

toJSON: ƒ d() v: ƒ () proto: Object_

Please help. Is there nay development on this issue? The error is coming in production. Users are not able to login. Please help. Thank you so much in advance.

Please check if changing network solves this issue. I am also facing this issue with firebase-js-sdk.. It is very bad experience

rahul-96 commented 3 years ago

Same error/issue. Suddenly. Did not change anything. It was working a while back perfectly. Pasting my error in the log which I'm getting from the code

firebase.auth().signInWithPopup(provider).then(function (result) {
...
}).catch(function (error) {
      // Handle Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
      // The email of the user's account used.
      var email = error.email;
      // The firebase.auth.AuthCredential type that was used.
      var credential = error.credential;
      console.log(error); //This it the error being consoled.
    }); 

The error in console:

_> u {code: "auth/network-request-failed", message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred.", a: null}

a: null code: "auth/network-request-failed" message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred." proto: Error constructor: ƒ u(a, b, c) Za: constructor: ƒ Error() message: "" name: "Error" toString: ƒ toString() proto: Object arguments: (...) caller: (...) length: 3 name: "u" prototype: Error {constructor: ƒ, v: ƒ, toJSON: ƒ} proto: ƒ ()

toJSON: ƒ d() v: ƒ () proto: Object_

Please help. Is there nay development on this issue? The error is coming in production. Users are not able to login. Please help. Thank you so much in advance.

It somehow just started working back again. No errors or issue anymore. Pretty sure it's some issue deep in the firebase-JS sdk since many people faced it the same way.

code-odyssey-trunk commented 3 years ago

WhatsApp Image 2020-11-12 at 10 41 31 AM I am also facing the same issue, and this is how it is happening to me. Mine is a react native app using expo. Firebase login is working fine in both expo and standalone app from my home network. But I sent apk file to my few friends, and one friend said he is getting this error (Error: A network error (such as timeout, interrupted connection or unreachable host) has occurred). He tried on multiple android phones (Pixel 4 and One plus nord). When he came to my home I tried to login from his phone and it worked. So now the firebase auth is working in my home network but not from my friend's.

akushylun commented 3 years ago

Some of my users getting this issue in angular version 10. Does some known workaround exist? Downgrade the firebase to some version?

"@angular/core": "~10.2.0", "firebase": "8.0.2",

fersucho commented 3 years ago

Hey guys, I was having the same issue in an AngularJS app. In this comment: https://github.com/firebase/firebase-js-sdk/issues/20#issuecomment-313236458 It is explained that Firebase checks for navigator.online before doing the auth process, and sometimes (and in some cases, always) it receives a wrong answer. By adding the cordova-plugin-network-information to the project, it provides the correct answer to Firebase and the app works again. In my case, I tried with version 2.0.2 of the plugin without success, and then with version 1.2.1 and, my app started to work fine.

SpectorHacked commented 3 years ago

Also having this issue using Expo, can't connect through Specific Wifi, connected 3 clients that are connected to the same WiFi,1 client works and 2 doesn't work, using Expo SDK 39. Any Updates?

HasanAboShally commented 3 years ago

I'm facing the same issue! Any update or workarounds please?

HasanAboShally commented 3 years ago

In my case the issue was resolved by changing the authDomain to {{APP_ID}}.firebaseapp.com instead of {{APP_ID}}.web.app

lewischa commented 3 years ago

Seeing the same issue here on firebase@8.2.6.

Was planning to switch from AWS for a small project but looks like this issue's been around for almost a year now. Got stoked at how easy things are supposed to be to set up, and immediately ran into this!! 😬 😞

rifat-dhrubo commented 3 years ago

Well we were having the same issue on our website. Turns out for us the problem was that we switched hosting from firebase to vercel. And the route that was loading the pop up "_example.com/_auth/apiKey?... " was not free anymore. Chrome was not showing anything but firefox was showing our 404 page. So, we figured it was a DNS issue. We got it to working by switching to the default auth domain. We are now working on configuring a custom auth sub domain for our site. I will post an update if we figure that out

ayyfahim commented 3 years ago

I was facing the same issue. It turned out that I was caching everything on my service worker js file. So I disabled these domains. if ( url.origin === "https://securetoken.googleapis.com" || url.origin === "https://apis.google.com" || url.origin === "https://www.googleapis.com" ) { return; }

iamdevlinph commented 3 years ago

Our react app is suddenly this issue. Already disabled service workers. Also verified the Sign in with Google button is not in a form.

tuancaraballo commented 2 years ago

Running into the same issue. Have tried everything said here, except for switching to a different product :(

DonLuc commented 2 years ago

It looks like we're rocking on the same boat. I had createUserWithEmailAndPassword working well for a few hours on my Ionic App, running on Angular, and using AngularFireAuth.

What surprises me is that invoking AngularFireAuth's sendPasswordResetEmail works well without resulting in this troubling authError.

These are the versions of the Angular, Ionic, and firebase related dependencies I'm using:

Please kindly unblock me.

emthomas commented 2 years ago

facing the same on flutter in iOS.

emthomas commented 2 years ago

Ok not sure if that is the case for react-native, but for me and flutter, looks like it was a caching issue. Once I do clean with flutter clean (which cleans my XCode workspace, build folder, cache, etc...) it works fine.

Adefunke commented 2 years ago

Had the same issue but discovered that I was not passing in strings into 'createUserWithEmailAndPassword', I was passing in elements. Once, I switched to strings, I stopped getting auth/network-request-failed error.

mayankkataria commented 2 years ago

I'm still facing this issue with firebase emulator on angular. Is there any solution or workaround for it?

mayankkataria commented 2 years ago

I'm still facing this issue with firebase emulator on angular. Is there any solution or workaround for it? And I'm shocked that it's still open since 2 years.

rupakhetibinit commented 2 years ago

Well, looks like it's still not fixed because I'm facing the same error.

lghimfus commented 2 years ago

@code-odyssey-trunk, @SpectorHacked (hope you were not really hacked)

Did you find out eventually what was causing the issue?

I'm facing the same issue and it's a really weird one. I have to switch through the wifi networks and it somehow eventually works...