re: Don't make that function async. VIEW POST


"Node process will have to start/stop and save/recover every function's execution state"

async/await is just syntactic sugar for Promises, which are essentially a callback abstraction. There's really no concept of starting/stopping.


Hey Asti,

I'm not sure about async/await being just syntactic sugar for Promises. Sure it was made to make it work with promises easier. If you've worked with Generators before, the concept of "awaiting" a function might look familiar to the concept of "yielding" a result. In both cases, you're giving the control back to the caller. When I say that the function start/stop and save/recover, I refer to this mechanism.

In fact, when you're targeting the browser when there's not much support for async/await syntax, you can use Babel to compile your async/await code to a generator which will yield until all the promises are resolved!. This article explains the concept in a very succinct way -


Both yielding and await rewrite the code behind the scenes to a state machine which handles control flow, to behave like co-routines. It's not special in any respect - it could well be user code. There's little overhead other than a few jump tables.

code of conduct - report abuse