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

190
Views
Will events be emitted / captured while awaiting for a promise?

I'm kinda new to nodejs and I'm familiarizing myself with the event loop, queue, etc.

I was wondering what happens while I'm awaiting for a promise to resolve, regarding events. Will events be emitted while awaiting? (I'm subscribed to a message broker, getting a message triggers an event). Will the callbacks that are called on event be queued in the event queue?

I know that the callback won't be executed until the promise resolves but will the events be triggered?

Thanks ^^

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

0

When events are registered, their emission is simply controlled by whatever makes them emitted. However, the callback registered to handle the event would go first into the event queue, and their queue position is not determined by what other promises are awaiting resolution, rather the position is determined by whatever promises have been resolved or rejected and whatever events have been emitted ahead of the presently emitted event, and they will all wait for the call stack to be cleared before they are invoked in turn. The event loop is the process of doing that, that is, it executes tasks from the event queue only when the call stack is empty i.e. there is no ongoing task.

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!