Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

234
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda