Skip to content

feat(blog): refresh asynchronous-flow-control.md #7972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ahm4dd
Copy link

@ahm4dd ahm4dd commented Jul 10, 2025

The previous version of the Asynchronous Flow Control guide relied on callback-based patterns which, while historically important, led to "callback hell" and are no longer considered best practice.

Changes include:

  • Replacing the callback-hell example with a modern async/await section to introduce the reader to a better solution.

  • Rewrote all core examples (In Series, Parallel, Limited Parallel) to use async/await, Promise.all, and Promise.race.

  • Simplified the Beer Song problem explanation while maintaining the details intact.

  • Corrected minor mistakes that could result in a misunderstanding.

Description

Changes include:

  • Replacing the callback-hell example with a modern async/await section to introduce the reader to a better solution.

  • Rewrote all core examples (In Series, Parallel, Limited Parallel) to use async/await, Promise.all, and Promise.race.

  • Simplified the Beer Song problem explanation while maintaining the details intact.

  • Corrected minor mistakes that could result in a misunderstanding.

Validation

The new text content that was added had been verified through the MDN docs.
All the added code had been tested and verified to serve the teaching purposes of the Asynchronous Flow Control documentation.

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

…lanations

The previous version of the Asynchronous Flow Control guide relied on callback-based patterns which, while historically important, led to "callback hell" and are no longer considered best practice.

Changes include:

* Replacing the callback-hell example with a modern async/await section to introduce the reader to a better solution.

* Rewrote all core examples (In Series, Parallel, Limited Parallel) to use async/await, Promise.all, and Promise.race.

* Simplified the Beer Song problem explanation while maintaining the details intact.

* Corrected minor mistakes that could result in a misunderstanding.

Signed-off-by: Ahmed Emad <ahmed.emad.edu@gmail.com>
@ahm4dd ahm4dd requested a review from a team as a code owner July 10, 2025 16:41
Copy link

vercel bot commented Jul 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Jul 11, 2025 1:12am

@avivkeller avivkeller changed the title docs: update and refactor async flow guide using async/await and better explanations feat(blog): refresh asynchronous-flow-control.md Jul 10, 2025
@avivkeller
Copy link
Member

Isn't the whole point of this article the callback pattern? We have separate articles for async/await (https://nodejs.org/en/learn/asynchronous-work/javascript-asynchronous-programming-and-callbacks and https://nodejs.org/en/learn/asynchronous-work/discover-promises-in-nodejs)

@ahm4dd
Copy link
Author

ahm4dd commented Jul 10, 2025

Isn't the whole point of this article the callback pattern? We have separate articles for async/await (https://nodejs.org/en/learn/asynchronous-work/javascript-asynchronous-programming-and-callbacks and https://nodejs.org/en/learn/asynchronous-work/discover-promises-in-nodejs)

That is true, I initially thought it will be redundant but I do not see the point of writing the examples using callbacks ( noting that it is talked about here here).

So why not have it in the way I wrote it?

@ahm4dd ahm4dd closed this Jul 10, 2025
@ahm4dd ahm4dd reopened this Jul 10, 2025
Copy link

codecov bot commented Jul 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.13%. Comparing base (cc36077) to head (485c9d4).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7972      +/-   ##
==========================================
+ Coverage   73.07%   73.13%   +0.05%     
==========================================
  Files          95       95              
  Lines        8358     8358              
  Branches      218      217       -1     
==========================================
+ Hits         6108     6113       +5     
+ Misses       2249     2244       -5     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@benhalverson benhalverson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cat Apple

Signed-off-by: Ahmed Emad <ahmed.emad.edu@gmail.com>
Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, but I just don't think that this is something that's worth pursuing. The way I see it, we have multiple articles describing how to use async/await, and this article describes how to use callbacks. It even warns users about "callback hell" in an earlier paragraph. If you strongly feel that this article is really so bad, perhaps it should be rewritten entirely. I don't think it makes sense to introduce users to one concept (Callbacks), only to follow-up with how it's not viable.

If other @nodejs/nodejs-website members disagree, I'll rescind this block, but for the time being, it stands.

Copy link
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with aviv

@ahm4dd
Copy link
Author

ahm4dd commented Jul 11, 2025

I'm sorry, but I just don't think that this is something that's worth pursuing. The way I see it, we have multiple articles describing how to use async/await, and this article describes how to use callbacks. It even warns users about "callback hell" in an earlier paragraph. If you strongly feel that this article is really so bad, perhaps it should be rewritten entirely. I don't think it makes sense to introduce users to one concept (Callbacks), only to follow-up with how it's not viable.

If other @nodejs/nodejs-website members disagree, I'll rescind this block, but for the time being, it stands.

We also have another article that describes Callbacks, this article is not specific to Callbacks, for a lot of people, this article is about asynchronous flow control, which is - Like you guessed - not limited to explaining Callbacks. And since it already warns about "Callback hell" why would we show people the problem without immediately giving them the escape route? It's like showing some a broken car and then making them read another book just to find out there's a perfectly good one over there.

I am not saying that Callbacks are useless, it's just that async/await is where it's at now, it makes the learning path a lot smoother, you know? I did not like reading that article and to be honest, but a re-write sounds like a lot of work for just fixing a small issue.

Anyway, I am happy to tweak some of the changes in this PR to make it fit it in some way, perhaps with few modifications, and some of the changes can be moved to other articles.

TL;DR: Helpful PR, merge please.

@ovflowd
Copy link
Member

ovflowd commented Jul 11, 2025

TL;DR: Helpful PR, merge please.

I don't think you have the right to say what we should or not merge.

That said, @avivkeller it's not up to our team to say what should or not be the content here. The block is fine, but kinda contradicts the content vs code responsibility of the website team.

I believe we should have @nodejs/collaborators to chime in on this regarding if this content does make sense or not. Maybe @mcollina has some opinions on this.

@ovflowd
Copy link
Member

ovflowd commented Jul 11, 2025

(Note that I haven't checked the content changes here, so I'm not aware of what got changed or not, I'll give it a read later)

@avivkeller
Copy link
Member

@ahm4dd

And since it already warns about "Callback hell" why would we show people the problem without immediately giving them the escape route?

Because, in my opinion, it convolutes the article, when we already have other articles explain this. If you want to show users the "escape route", that's perfectly fine, let's link to https://nodejs.org/en/learn/asynchronous-work/discover-promises-in-nodejs, but when we add new paragraphs describing something that is already described elsewhere, it increases the maintenance burden of the website.

TL;DR: Helpful PR, merge please.

As @ovflowd said above. We are the maintainers of the site, and have the final say on what does or does not get merged. We aren't saying your PR is not helpful, almost every PR is, however, we follow a consensus seeking model, and will therefore not merge this PR until consensus is reached.


@ovflowd

but kinda contradicts the content vs code responsibility of the website team.

No working group has taken ownership of this content (AFAIK we don't have a working group assigned to async/Promise behavior, so, per the responsibility, we have editorial ownership.

As an aside, and this is most definitely something for a separate issue, but also worth mentioning: We, in my opinion, should be allowed to act as an editorial team for any and all content on the Node.js Website. While Core Collaborators should obviously have the final say when it comes to content they have the expertise on, the Website Team should still be able to provide editorial oversight to ensure consistency, clarity, tone, accessibility, and alignment with the broader communication standards of the project's website.

It feels contradictory to say the Website Team is not editorial, while at the same time acknowledging that we write and maintain a large portion of the site’s content. If we're producing content, shouldn't we also be trusted to provide editorial oversight for that content? And if we are the default editors for unowned sections, doesn’t that imply a kind of editorial responsibility already?

@ahm4dd
Copy link
Author

ahm4dd commented Jul 11, 2025

I don't think you have the right to say what we should or not merge.

Looks like I did not clarify the joke enough.

Anyhow, for the changes, I think there's a mistake with the little concurrency note, it should be removed soon, thanks for your time.

@ahm4dd
Copy link
Author

ahm4dd commented Jul 12, 2025

Because, in my opinion, it convolutes the article, when we already have other articles explain this. If you want to show users the "escape route", that's perfectly fine, let's link to https://nodejs.org/en/learn/asynchronous-work/discover-promises-in-nodejs, but when we add new paragraphs describing something that is already described elsewhere, it increases the maintenance burden of the website.

Fair argument.

It is true that we should not add a section to explain what async/await are, but instead, we could briefly demonstrate its purpose and then continue using it throughout the article, just like how the article introduced the use of callbacks (Instead of telling people "Oh yeah, there's a better solution over there, but we will continue with our current", we could just use the other one, simple :)).

@Qard
Copy link
Member

Qard commented Jul 12, 2025

This should probably just be a new page.

Async flow control with callbacks definitely still needs a doc explaining it as many find it confusing and, even if much code lately is async/await-based, there's still a lot of ecosystem code with callbacks. Core still uses them in many places too. The patterns need to be understood. Having content explaining the async flow control of async/await is valuable too, but not at the cost of losing documentation of how it works with callbacks.

The callback page could be retitled to be specifically about callbacks and then make another using the original title or a title specific to async/await to differentiate them.

@avivkeller
Copy link
Member

The callback page could be retitled to be specifically about callbacks and then make another using the original title or a title specific to async/await to differentiate them.

FWIW we have a page describing Promises and async/await, but I like your proposal

@ahm4dd
Copy link
Author

ahm4dd commented Jul 12, 2025

FWIW we have a page describing Promises and async/await, but I like your proposal

Yeah, we also have another page explaining Callbacks, this is not limited to how async/await work, but the changes use async/await.

Did you read the changes?

@ahm4dd
Copy link
Author

ahm4dd commented Jul 12, 2025

The callback page could be retitled to be specifically about callbacks and then make another using the original title or a title specific to async/await to differentiate them.

I like that, but would you prefer having 2 separate pages regarding this topic (Like what we have with Callbacks and Promises) or have it all in one article but with separate sections?

I would like to hear your opinion so that I can start working on the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants