Firebaseui-web: updateCurrentUser failed: First argument "user" must be an instance of Firebase User or null.

Created on 23 Dec 2018  路  7Comments  路  Source: firebase/firebaseui-web

Describe your environment

  • Operating System version: Mac
  • Browser version: Google Chrome Version 71.0.3578.98
  • Firebase UI version: "react-firebaseui": "^3.1.2"
  • Firebase SDK version: "firebase": "5.7.1"

Describe the problem

I'm using the https://github.com/firebase/firebaseui-web-react wrapper
My implementation it seems to do the login properly on firebase (as i can see the mail logged on "Users" but on my react app I'm getting this error all the time

updateCurrentUser failed: First argument "user" must be an instance of Firebase User or null.  Dismiss

No signInSuccessUrl redirection or signInSuccessWithAuthResult callback works after this error

    signInSuccessUrl: '/',
    callbacks: {
      signInSuccessWithAuthResult: function(authResult, redirectUrl) {
        console.log(authResult)
        console.log(redirectUrl)
        return true
      }
    }

I have no clue about how to debug this or what would be the error

Any ideas?

Most helpful comment

I hit this error, and the reason was we had two copies of Firebase (one we were including manually, one which npm was pulling in). That caused this bug because for some reason it was using the manual one we specified to invoke the FirebaseUI React component and then calling updateCurrentUser() in the underlying npm version of Firebase (and thus checking the type there). Both versions of Firebase were 5.7.1 so it wasn't a versioning issue, it was that we had two copies of Firebase and the component wasn't consistent about which one it used (which I'd argue is a bug in FirebaseUI or the React-FirebaseUI module, but I ain't dying on that hill).

All 7 comments

Same problem here, but this happens to me only when using typescript. I made a test with similar code with javascript with the same environment and same code and it did work.

The actual firebase auth works. A new user is been created to firebase app but then something goes wrong. I have not yet been able to find the exact place where.

@juanmaguitar I tried with "firebase": "5.7.1" and "firebaseui": 3.2.0 as react-firebaseui used. But cannot reproduce the error you mentioned. updateCurrentUser is called here for every sign-in operation: https://github.com/firebase/firebaseui-web/blob/master/javascript/widgets/authui.js#L1653. And the error is thrown from firebase core SDK complying about the provided argument is not a User object. So I'd appreciate it if you could print some trace of the user object passed to updateCurrentUser and build the firebaseui library yourself to help us investigate the issue. Otherwise, without being able to reproduce, it's really hard to help.

I hit this error, and the reason was we had two copies of Firebase (one we were including manually, one which npm was pulling in). That caused this bug because for some reason it was using the manual one we specified to invoke the FirebaseUI React component and then calling updateCurrentUser() in the underlying npm version of Firebase (and thus checking the type there). Both versions of Firebase were 5.7.1 so it wasn't a versioning issue, it was that we had two copies of Firebase and the component wasn't consistent about which one it used (which I'd argue is a bug in FirebaseUI or the React-FirebaseUI module, but I ain't dying on that hill).

@WriterDuet I don't quite follow. If the two versions are the same, why would that cause the type error?

Also hit this - can't explain what was going on, but eventually fixed it by replacing some imports of @firebase/... that I'd copied from a tutorial https://github.com/LazyFatArrow/vue-quiz-pwa/blob/master/src/firebase.js with the non-@ versions

If you are using loading firebase by via scripts then you can't use the npm versions, and also not the firebaseui npm version.

I had the same issue bue resolved it by loading all the firebase and firebaseui scripts via