Skip to content

Promise never resolves when performing an action on a Firestore DB after calling auth.createUserWithEmailAndPassword #3218

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

Closed
nefarioustim opened this issue Jun 16, 2020 · 12 comments · Fixed by #4971

Comments

@nefarioustim
Copy link

nefarioustim commented Jun 16, 2020

  • Operating System version: MacOS Mojave 10.14.6
  • Browser version: Firefox 78, Chrome 84, Safari 13.1.1
  • Firebase SDK version: 7.15
  • Firebase Product: auth, firestore

When attempting to follow a call to auth.createUserWithEmailAndPassword with code that updates or creates a Firestore document (in my initial case it was a firestore.collection().doc().set(), but in testing it was the same for an .update()), the returning Promise never resolves and simply hangs.

Here is a simplified example of the Vuex actions I am calling in my code that exhibit this issue:

    signUserUp ({ dispatch, commit }, payload) {
      const $app = this.$app
      commit('setLoading', true)
      commit('clearError')

      return fb.auth
        .createUserWithEmailAndPassword(payload.email, payload.password)
        .then(userRef => {
          $app.logInfo('Created auth user', {'email': payload.email})

          return dispatch("createAccount", payload)
        })
        .catch(error => {
          commit('setLoading', false)
          commit('setError', error)
          $app.logError('Error signing up user', {error: error.message})
        })
    },

    createAccount({ commit, dispatch }, payload) {
      const $app = this.$app
      return fb.db.collection(COLLECTION)
        .doc(payload.account)
        .set({
          'created': new Date().getTime(),
          'updated': new Date().getTime(),
          'active': true,
          'account': payload.account,
          'legalName': payload.legalName,
          'country': payload.country,
          'currency': payload.currency,
          'industry': payload.industry,
          'email': payload.busemail || payload.email, // Allow for signup form
          'about': payload.about,
          'tags': payload.tags,
          'type': payload.type
        })
        .catch(error => {
          commit('setLoading', false)
          commit('setError', error)
          $app.logError('Error creating account', {error: error.message})
        })
    }

I have managed to temporarily resolve this issue by rolling back to version 7.14 of the SDK, but obviously I'm interested in a more longterm fix that allows me to continue upgrading the SDK.

Possible related to #3120 and raised following comments there.

@schmidt-sebastian
Copy link
Contributor

@nefarioustim Thanks for reporting.

This is likely fixed in v17.15.1, which includes #3184. Do you mind verifying your issue with this version?

@gragland
Copy link

gragland commented Jun 16, 2020

@schmidt-sebastian I'm having the same problem and v17.15.1 didn't fix it for me. A few other details that may be helpful:

  • I'm able to work around the issue by wrapping the write in a short setTimeout. As long as the write is called after onAuthStateChanged fires then it succeeds.
  • It only happens if I log out and then call createUserWithEmailAndPassword without a hard refresh of the browser. If I refresh the browser after logging out then the issue is not present.

@nwaughachukwuma
Copy link

Thanks, @gragland. @schmidt-sebastian this also happens when using social auth (redirect or popup) and I had made a comment in #2923 (although closed).

@google-oss-bot
Copy link
Contributor

Hey @nefarioustim. 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!

@nefarioustim
Copy link
Author

Hey @schmidt-sebastian; apologies for the delay, but I can confirm I am experiencing the same issue with 17.5.1. :(

@sunteago
Copy link

sunteago commented Jul 9, 2020

Experiencing the same issue after calling auth.createUserWithEmailAndPassword, had to go to v7.14.4 for the moment that seems to work fine

@pelagaggi
Copy link

pelagaggi commented Jul 19, 2020

I was experiencing the same issue on a ReactJS based application, the promise returned the first time I created a user but after that never returned, I have tried downgrading

After downgrading from 7.16.1 to 7.14.4 as suggested by @sunteago changing in package.json and index.html

package.json
    "firebase": "7.14.4",
  <!-- The core Firebase JS SDK is always required and must be listed first -->
  <script src="https://kiyo-ngo-sinergia.firebaseapp.com/__/firebase/7.14.4/firebase-app.js"></script>

  <!-- TODO: Add SDKs for Firebase products that you want to use
        https://firebase.google.com/docs/web/setup#available-libraries -->
  <script src="https://kiyo-ngo-sinergia.firebaseapp.com/__/firebase/7.14.4/firebase-analytics.js"></script>

I notice that my URL was showing sensitive info which suggested that could be something else than firebase.

?firstName=xxxx&lastName=xxxx&email=xxxx%40gmail.com&password=xxxx&policy=

It turns out that I was not preventing an event propagation on my login Form submit. After fixing that I Changed Back to version 7.16.1 and now my promise is returning.

Hope this helps someone

@sunteago
Copy link

sunteago commented Jul 19, 2020

I am also working with React. Now I upgraded to v7.16.1 and I am no longer experiencing this problem, I think it's now solved.

@LandazuriKastilloCode
Copy link

Thanks sunteago indeed it is no longer present on v7.16.1. I was starting to lose my mind with this bug.

@hubertkuoch
Copy link

Not trying to necro this one, but looks like this issue has been re-introduced (currently using v8.6.3). Same behaviour as described by @gragland, wrapping subsequent writes to Firestore inside a setTimeout does the trick, but still quite annoying to add back this ad hoc hacky wrapper.

@schmidt-sebastian
Copy link
Contributor

This should be fixed by #4971

@rrluthi
Copy link

rrluthi commented Jun 15, 2021

This is happening on the beta 9.0.0-beta.3 as well.

@firebase firebase locked and limited conversation to collaborators Jul 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants