Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
¿Cómo verificar si la extensión Firebase Stripe ha terminado de crear el documento de cliente/usuario?

Estoy usando la extensión Firebase Stripe .

Cuando se agrega un usuario a Firebase, la extensión Stripe usa Cloud Functions para crear un documento de users en Firestore Datastore.

En mi aplicación, tengo una función que crea un usuario de Firebase y luego intenta actualizar el documento Firestore de los users correspondientes.

Pero a veces Cloud Functions no ha terminado de crear el documento de users y devuelve este error:

 No document to update: projects/APP_NAME/databases/(default)/documents/users/KHaY21FSUasdfOXFS123Kfge85VA3

Para solucionar este problema, estoy usando un tiempo de timeout que se detiene durante unos segundos antes de continuar. No es una solución ideal.

En cambio, quiero saber si la extensión Firebase Stripe ha terminado de crear el documento de los users antes de continuar.

¿Cómo se puede hacer eso?

Aquí está la función de mi aplicación:

 export const useCreateUserWithEmailAndPasswordTask = () => { const updateDocTask = useUpdateDocTask(); return useTask(function* ( signal, email: string, password: string, firstName: string, lastName: string, ) { // Create the user in Firebase // The Firebase Stripe extension will now use Cloud Functions to also create a 'users' doc with related user info const userCredential: UserCredential = yield createUserWithEmailAndPassword( auth, email, password ); // Now I wait 3 seconds to make sure the 'users' doc is created before updating it. // Without this timeout it will occasionally throw an error because updateDocTask is called before the 'users' doc is created // Is there a better way of doing this? yield timeout(3000); const updateDoc: void = yield updateDocTask.perform( 'users', userCredential.user.uid, { firstName: firstName, lastName: lastName, createdAt: timestamp, } ); return Promise.all([userCredential, updateDoc]); }); };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar oyentes en tiempo real en lugar de setTimeout() como se muestra a continuación:

 import { doc, onSnapshot } from "firebase/firestore"; const unsub = onSnapshot(doc(db, "users", "<USER_DOC_ID>"), (doc) => { // This function triggers whenever the document is created/updated/deleted console.log("Data: ", doc.data()); });

Verifique si doc.data() ya tiene datos en caso de que la extensión haya agregado un documento antes de que el usuario llegue a esta página.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!