Firebaseui-web: "updateCurrentUser failed" error on screen, after using 4.7.1 via ES module import

Created on 3 Nov 2020  Â·  11Comments  Â·  Source: firebase/firebaseui-web

Describe your environment

  • Operating System version: macOS
  • Browser version: Chrome 85
  • Firebase UI version: 4.7.1
  • Firebase SDK version: 8.0.0

Describe the problem

The ability to import as ES module in 4.7.1 is something I have been looking forward to. Bringing it in in my application, I found two problems. This issue describes the more crucial one, which I don't understand and can not find a way around.

After changing my code to use import instead of loading via the globals, and signing in with Google account, I see this:

image

I have no idea, where it comes from.

Steps to reproduce:

  1. Clone https://github.com/akauppi/GroundLevel-es-firebase-app
  2. Set up a Firebase project to work against (please read the README, until you can npm run dev:online).
  3. npm run dev:online

Open the browser at http://localhost:3001 and try Google sign-in.

Expected: one should get to the app
Actual: the above error is shown

Relevant Code:

Unfortunately, I don't have a minimum reproducing project available. Merely scouting, if other are also seeing this.

need-more-info

Most helpful comment

Same, local not working. Production seems fine.
edit: seems to be the buildDir location being within firebase functions folder

"@nuxtjs/firebase": "^7.5.0",
    "firebase": "^8.3.1",
    "firebaseui": "^4.8.0",
    // nuxt.config.js
     target: "static",

    services: {
      auth: {
        persistence: "local",
        initialize: {
          onAuthStateChangedAction: "onAuthStateChanged"
        },
        ssr: false // true doesn't work either...
      },
     buildDir: "../functions/.nuxt",  // It is this line that breaks it when running locally. 

All 11 comments

Thanks for reaching out--

Is there anything that's logged to the JS console (like a stack trace for example)?

@samhorlbeck Nothing out of the ordinary in the browser console. Is there something on the FirebaseUI side, to enable more tracing?

The error you are receiving is related to the core Auth library. I would investigate there first.

A quick search in your repo seems that you are creating wrappers or new references of the user. I suspect that could be related.

So you are saying this is not occurring with others.

@bojeil-google The wrapping code should not affect Firebase in any way. It has worked before, the only change was bringing ’firebaseui’ via ES import, instead of via globals (window.firebase and window.firebaseui).

The issue is unlikely to be related to firebaseui as I explained in my first comment.

We have not seen any other reports of this issue.

Try changing your auth import from import '@firebase/auth' to import 'firebase/auth';. That worked for us and this matches the firebase guidelines.

I saw your first comment (and appreciate the help). I am simply reporting that importing Firebase and FirebaseUI as browser-native ES modules does not currently work. To me, it does not play a huge role whether the reason is in the auth, the FirebaseUI or their mutual bridging.

Try changing your auth import from import '@firebase/auth' to import 'firebase/auth';. That worked for us and this matches the firebase guidelines.

That's a good point. I tried it, but it makes no difference. In fact, the latter is just a redirect to the former:

$ cat node_modules/firebase/auth/dist/index.esm.js
import '@firebase/auth';
//# sourceMappingURL=index.esm.js.map

I'll come back to this, eventually. For a couple of weeks, I likely have other work to do.

I have the same problem, in localhost only, using npm nuxtjs/firebase with npm firebase and npm firebaseui.

"@nuxtjs/firebase": "^7.1.1",
"firebase": "^8.0.2",
"firebaseui": "^4.7.1",

While it perfectly works in production.

Have now time to look into this.

@bojeil-google Thank you for your comments.

We have not seen any other reports of this issue.

I did find the issue discussed in #536 (Dec 2018 - May 2019).

Try changing your auth import from import '@firebase/auth' to import 'firebase/auth';. That worked for us and this matches the firebase guidelines.

I did. It doesn't change anything.

Did not find a way to make FirebaseUI live with ES modules.

Instead, wrote my own authentication components which is available as a web component. If anyone is interested, you find it here.

Same, local not working. Production seems fine.
edit: seems to be the buildDir location being within firebase functions folder

"@nuxtjs/firebase": "^7.5.0",
    "firebase": "^8.3.1",
    "firebaseui": "^4.8.0",
    // nuxt.config.js
     target: "static",

    services: {
      auth: {
        persistence: "local",
        initialize: {
          onAuthStateChangedAction: "onAuthStateChanged"
        },
        ssr: false // true doesn't work either...
      },
     buildDir: "../functions/.nuxt",  // It is this line that breaks it when running locally. 
Was this page helpful?
0 / 5 - 0 ratings