firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

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

Open shirlev-wix opened this issue 5 years ago • 67 comments

[REQUIRED] Describe your environment

  • Operating System version: Mac 10.14.6
  • Browser version: Chrome Version 79.0.3945.130
  • Firebase SDK version: 6.6.2
  • Firebase Product: auth (auth, database, storage, etc)
  • React Native version: 0.61.5

[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."
  • Works fine on the simulator when I'm not debugging.
  • Happens also for other teammates that work on the same project
  • Rebooting Chrome didn't help

Steps to reproduce:

Relevant Code:

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!

shirlev-wix avatar Feb 20 '20 13:02 shirlev-wix

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 avatar Feb 20 '20 14:02 rommelpe

@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!

rommelpe avatar Feb 25 '20 14:02 rommelpe

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!

google-oss-bot avatar Mar 05 '20 02:03 google-oss-bot

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 avatar Mar 06 '20 15:03 shirlev-wix

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

shirlev-wix avatar Mar 22 '20 12:03 shirlev-wix

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",

kishansbs avatar Apr 03 '20 06:04 kishansbs

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()

nyenye avatar Apr 07 '20 20:04 nyenye

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

  • there is no form html tag used
  • the call to action button is a <button type='button'>Signup</button> element
  • no session cookie/token revocation happens

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

berndartmueller avatar May 18 '20 14:05 berndartmueller

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"

jefelewis avatar Jun 17 '20 19:06 jefelewis

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 => ...)

HassanAbass avatar Jul 01 '20 13:07 HassanAbass

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"

brloman avatar Jul 14 '20 10:07 brloman

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

frietkip avatar Jul 15 '20 06:07 frietkip

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.

avolkovi avatar Jul 15 '20 17:07 avolkovi

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.

HassanAbass avatar Jul 16 '20 03:07 HassanAbass

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!

google-oss-bot avatar Jul 23 '20 01:07 google-oss-bot

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

shirlev-wix avatar Jul 26 '20 06:07 shirlev-wix

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.

obrunopolo avatar Sep 17 '20 22:09 obrunopolo

@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:

  • Using a DNS proxy 8.8.8.8 for Android emulator.
  • Using a cell provider network on my dev Android device instead of any WiFi networks.

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

yzalvov avatar Sep 18 '20 07:09 yzalvov

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.

Georgemburu avatar Oct 06 '20 09:10 Georgemburu

@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 avatar Oct 14 '20 19:10 obrunopolo

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 🤷🏻‍♂️

emad-ir avatar Oct 23 '20 12:10 emad-ir

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.

rosalyntan avatar Oct 26 '20 21:10 rosalyntan

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>

MittalShruti avatar Nov 02 '20 07:11 MittalShruti

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 avatar Nov 02 '20 08:11 avinashg-wal

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

avinashg-wal avatar Nov 02 '20 08:11 avinashg-wal

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

rameshvishnoi90904 avatar Nov 08 '20 05:11 rameshvishnoi90904

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 avatar Nov 09 '20 06:11 viv3kk

@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.

viv3kk avatar Nov 09 '20 06:11 viv3kk

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: ƒ () [[FunctionLocation]]: auth.esm.js:411 [[Scopes]]: Scopes[4] 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.

rahul-96 avatar Nov 09 '20 13:11 rahul-96

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: ƒ () [[FunctionLocation]]: auth.esm.js:411 [[Scopes]]: Scopes[4] 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

viv3kk avatar Nov 09 '20 13:11 viv3kk