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

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

Closed
juanmaguitar opened this issue Dec 23, 2018 · 7 comments

Comments

@juanmaguitar
Copy link

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?

@mindhivefi
Copy link

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.

@wti806
Copy link
Contributor

wti806 commented Dec 28, 2018

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

@WriterDuet
Copy link

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

@wti806
Copy link
Contributor

wti806 commented Jan 7, 2019

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

@leoshaw
Copy link

leoshaw commented Jan 8, 2019

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

@u12206050
Copy link

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 <script> tag instead of npm.

@surferjeff
Copy link

I saw this same error using vuejs-cli, webpack, typescript, and a locally built firebaseui node module.

This work-around worked for me:

Only list firebaseui in my project's packages.json:

  "dependencies": {
    "firebaseui": "file:../../../firebaseui-web",
   }

Import the firebase modules from firebaseui's node_modules directory:

import firebase from "firebaseui/node_modules/firebase/app";
import "firebaseui/node_modules/firebase/functions";
import * as firebaseui from "firebaseui";
import "firebaseui/dist/firebaseui.css";

I'm afraid I've built a house of cards. Is this technically sound? Is there a better way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants