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

156
Views
Does main thread execute the Promise code or does it get added to an js engine api?

Javascript engine executes code in the single main thread.

The main thread will not block on an async function call unless the await keyword is used await fnnane();

When there is an async fucntion like setTimeout or fetch, then it is handed over to the respective Javascript engine api to work on separate to the main thread.

The response (and subsequent function code) is added to the task queue.

But when there is a Promise as shown below, then where does it get passed or does the main thread execute it?

async function foo(i) {
  await new Promise(resolve => setTimeout(resolve, 5000));
  console.log('Completed foo', i);
}
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!