DEV Community

Discussion on: Asynchronous Javascript

Collapse
 
dcsan profile image
dc

At first I thought this is an odd post for dev.to as you do not add anything but just ask questions. But then I think these are very interesting questions, so I hope you will follow-up with some answers later!

perhaps you can make some code with Typescript compiler. My understanding is that some promises code is handled internally by JS runtime which makes it hard to trace, but typescript tries to reduce it to a dispatcher loop.

In my case step-through debugging with typescript async/await blocks I often see a dispatcher loop where a list of promises is handled until exhausted.

I think what is happening is internally any 'await' callback gets added to an internal stack. But it is unclear how the stack list of internal event queue is pulled and invoked by the end of external events such as a web request or IO without blocking, unless JS runtime engine internally did have some type of threading.

Let us know what you find out!