Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

425
Vistas
Exception from a finished function: Error: There is no user record corresponding to the provided identifier

This firebase function keeps track data changes of a firestore collection and push it to the Existing contact of a CRM.

// LISTENER
exports.listenData = functions.https.onRequest(async(request, response) => {

  // Keep track of profile collection
  db.collection('profile').onSnapshot(async(querySnapshot) => {
    console.log('change in profile');

    let changedDocs = querySnapshot.docChanges();
    for (let i = 0; i < changedDocs.length; i++) {
      let change = changedDocs[i];

      if (!change.doc.exists) {
        continue;
      }
      console.log('change in profile in loop');

      let profileDocData = change.doc.data();
      let body = {
        "customField": {
          "subscription_expiration_date": ""
        }
      };

      let user = await admin.auth().getUser(change.doc.id);

      // profile
      try {
        body.customField.subscription_expiration_date = profileDocData.expiration_date;
      } catch (error) {
        body.customField.subscription_expiration_date = '';
      }

      console.log("Profile changed by " + user.email ? ? "Unknown");

      try {
        let res = await axios.get('EndPoint URL ?email=' + user.email, {
          headers: {
            "Authorization": "Bearer Token"
          }
        });

        let userId = res.data.contacts[0].id;
        axios.put('EndPoint URL /contacts/' + userId, body, {
          headers: {
            "Authorization": "Bearer Token"
          }
        });

      } catch (error) {
        console.log('Error on profile');
      }
    }
  });


  response.send("Listening...");
});

Output:

Screenshot of Console

Error

Exception from a finished function: Error: There is no user record corresponding to the provided identifier.

I'm confused here! Anyone?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

First of all, when you send a response back to the client, the function is closed (that's why you get "a finished function"). So, if you want to monitor changes, you should set up a trigger: https://firebase.google.com/docs/functions/firestore-events.

The error itself says there is no user in the Firebase Authentication section with the id you are providing the admin.auth().getUser with.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda