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

125
Views
Does Javascript finish executing async function even after the rest of the code has finished executing?

This is what I tried -

async func1(){
 // do asynchronous calls with await
 console.log("call finished");
}

func2(){
 func1(); // without await
 console.log("func2 finished");
 return;
}

func2();

The output was - func2 finished call finished. So even after the parent function completed execution, the async function still completed what it was intended for.

Will this work in case of an API where we are returning something to an external service? Like cloud functions -

async func1(){
 // do asynchronous calls - post db using await
 console.log("call finished");
}

func2(){
 func1(); // without await
 return response.status(200).send("");
}

func2();

Will the database call complete even if the response.send is executed first provided I don't await for the first function to finish execution?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yes, the Promise returned by an async function is only a handle that lets you chain logic onto the asynchronous value or timing provided by the function. You don't have to do anything with it. If you don't use .then or await to chain off of it, the async function still runs and goes through all its code - it's just that the Promise it returns doesn't get used elsewhere.

That said, dangling promises are usually a bad idea - in most cases, you probably should chain a .then or .catch onto a promise.

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!