Do await statements unblock synchronously?

/#!/JoePea joe at
Mon Apr 11 16:50:42 UTC 2016

Is code that follows an await statement supposed to get executed in
the same tick in which the statement's awaited promise is resolved?

let resolve = null
const somePromise = new Promise(r => resolve = r)

~async function() {
  await somePromise

// ... time passes

Should `doSomething()` fire in that same tick as when `resolve()` is
called? I already know that if this is true, there's at least one
exception: `await Promise.resolve()`, in that the await statement must
still defer to a future tick even though the given Promise is already
resolved. I suppose I'm asking for cases where the await statement's
promise is unresolved.

- Joe

More information about the es-discuss mailing list