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

233
Views
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
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!