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

235
Vistas
Avoiding async/await with a blocking function?

I have a low level common function which is the bottom of the call tree in many places.

There is an async transaction, and I want to block until the async request completes, before returning.

I could use await. E.g await admin.database().ref(url).update(value);.

BUT, if I use await then I must mark the function as async. Which means that must mark all of its callers as async, and all of theirs, all the way up to the top.

Would it be evil of me to code my blocking function like this?

Perhaps I am missing something? Please be gentle, I am relatively new to JS. Thanks in advance for any help,

/**
 * Perform a blocking write to the database. It is the responsibility of the caller to catch any exceptions.
 * 
 * @param {string} url - the URL of the node to be updated.
 * @param {string | Object} value - the value to be written
 */
expors.updateDatabase = function(url, value){
    admin.database().ref(url).update(value).then(() => {
        return;
      });
}

This might sound opinion based, and I won't deny that I would be happy to hear about industry standard best practise, but what I am really after is whether there is any technical reason not to do this.

about 4 years ago · Juan Pablo Isaza
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