React + Firebase app and Network Error at auth.esm.js:255 while trying to sign in with Google

Viewed 1746

I am losing my hope at solving a Network Error in my Firebase/React app. The error Uncaught Error: Network Error at auth.esm.js:255 shows up in the console sometimes, and at other times it simply won't show and the user gets logged in with Google successfully.

While searching for an answer, I couldn't find anything conclusive (be it in Stack Overflow or Github issues). The Firebase documentation only shows Thrown if a network error (such as timeout, interrupted connection or unreachable host) has occurred about this.

Below is my piece of code for the log in component.

useEffect(() => {
    auth
      .getRedirectResult()
      .then(function (result) {
        if (result.credential) {
          const token = result.credential.accessToken
          setIdToken(token)
          history.push('/')
        }
        const user = result.user
        setUsername(user.displayName)
      })
      .catch(function (error) {
        var errorCode = error.code
        var errorMessage = error.message
        console.log('errorCode and errorMessage: ', errorCode, errorMessage)
      })
  }, [])

function handleSignInWithGoogle() {
    signInWithGoogle()
    setLoading(true)
  }

  //then, inside of my return statement

<button onClick={() => handleSignInWithGoogle()}> Sign in with Google </button>

And this is what inside of my Firebase file

firebase.initializeApp(firebaseConfig)
export const firestore = firebase.firestore()
export const auth = firebase.auth()
export const provider = new firebase.auth.GoogleAuthProvider()
export const signInWithGoogle = () => auth.signInWithRedirect(provider)
1 Answers

Its possible you have some debugger on the code or any blocking process.

Aparently firebase has a timeout and after that time pass (few seconds on my case) it doesnt allow you, as soon as took out the debugger that was blocking the first start it got solved.

Related