# await all promises in a code block

**URL:** <https://es.discourse.group/t/await-all-promises-in-a-code-block/2382>\
**Category:** 💡 Ideas\
**Created:** [June 13, 2025, 1:01pm UTC](https://es.discourse.group/t/await-all-promises-in-a-code-block/2382 "2025-06-13T13:01:53Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![lentschi](https://avatars.discourse-cdn.com/v4/letter/l/c77e96/32.png) [@lentschi](https://es.discourse.group/u/lentschi)\
**Post date:** [June 14, 2025, 7:57am UTC](https://es.discourse.group/t/await-all-promises-in-a-code-block/2382/4 "2025-06-14T07:57:12Z")

</div>

> [@lentschi](#):
>
> Ah, sorry, this is more or less a duplicate of this (Looked for it, but couldn't find it yesterday):

However... in that thread, the proposal I accidentally duplicated got shot down early and other alternatives were discussed.

I don't quite agree with the mentioned disadvantages of that proposal though:

> [@Concurrent Async and Normal Await Evaluation Blocks](https://es.discourse.group/t/concurrent-async-and-normal-await-evaluation-blocks/827/6):
>
> I don't like this kind of magic. Reasoning about async code is already hard, having the language do the magic for you will make folks forget what happens under the hood, until it does not work as expected.

Well but `async` is _already_ doing "magic": It turns every return value into a promise, regardless of the function's contents. And `await` magically determines, if the passed expression actually is a Promise.

The proposed `sync` keyword (or `await` block in the other thread) would do the same but additionally `await` every expression inside the code block (sequentially in the order of expression evaluation).

> [@bakkot](#):
>
> The `await` points are important enough to warrant being explicitly annotated. I don't think there's any appetite to make them more implicit.

Yeah, well "appetite" is something very subjective 😄  
But I agree that in web programming `await` is always "important enough to being explicitly annotated" 👍  
It's just for batch-style scripts that this would really make things more readably IMO. (For code intended for browsers it might even make sense to prohibit the proposed keyword via `eslint`.)

Consider node's `fs.readFile` vs `fs.readFileSync` for example: I've always found it quirky to have a second method that essentially does the same as the first, only that one returns a Promise and the other actually blocks the execution until the file has been read.  
But I understand _why_ they additionally introduced `fs.readFileSync` - for the same reason I'm proposing `sync`: To not have thousands of `await` keywords cluttering batch-style scripts.

---

_[View the full topic](https://es.discourse.group/t/await-all-promises-in-a-code-block/2382)._
