You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Concurrent calls to auth.createUser() may create multiple user accounts with the same email address #2949
Firebase does not guarantee user email uniqueness in users in case duplicate & concurrent calls are made to auth.createUser(), despite the "User account linking" setting in the Console being set to "Link accounts that use the same email". The API is not idempotent.
Users can never create multiple accounts with the same email address and sign-in method.
If calls to auth.createUser with the same email are separated enough in time (some tens of milliseconds?), the last call will raise a auth/email-already-exists error, which is the expected behavior.
Steps to reproduce:
Run this Firebase Admin JS script against a production Firebase environment, using node v20
// `auth` is a Firebase Admin auth instanceimport{auth}from"../src/admin.js";constc=()=>auth.createUser({email: "thor+duplicatetest@slowby.travel",displayName: "Test",});awaitPromise.all([c(),c()]);
Observe that two users were created with the same details, with different UIDs
Screenshot of the Firebase Console Auth dashboard
Workaround
Avoid concurrent calls to auth.createUser() with the same email address.
We were likely getting this issue because our front-end registration form would be submitted two times if double-clicked, which in turn lead to two concurrent auth.createUser calls in the back-end. Now we've debounced this call, which should avoid the issue in most circumstances.
More context
We are not using "Firebase Auth with Identity Platform"
We saw an increase in the frequency of this issue since we started using the Firebase Admin SDK for Firebase Auth account creation (5 cases over 2 months). In the years before, when we were still using front-end Firebase JS clients for Firebase Auth account creation, we only had 1 similar case. I assume the frontend client implements some kind of debouncing internally already?
Reacted by yuvalhermelin-fijoya, Oskar Franzén, Edwin Liu, kkb, cyran-ryan, Yuchao and Christopher Wilkinson
Activity
fix: debounce submit calls on the user registration form
fix: debounce submit calls on the user registration form