async/await are (almost) syntatic sugar for the plain-old Promise API, you could accomplish the same "blocking" behaviour using promise1().then(promise2).then(promise3) and so on, thus this is not a problem with async/await syntax per-se, IMO.
One using await should first know about the Promise API, so it'll know better how to use it
Absolutely, and even when knowing these tools some developers tend not to prioritize parallel executions for some reason. A colleague said the same thing as you after reading it, and it's very pertinent.
Been doing web development for ages. I love that I can just constantly be leaning something. There's always another topic to grasp or rabbit hole to fall into.
Education
2 years interactive design and web development, and a further 15 years of curiosity and tinkering
Promise chains are a problematic solution, as each '.then' produces another promise. What happens if an earlier 'then' throws and there's no catch or other error handling? Memory leak
Been doing web development for ages. I love that I can just constantly be leaning something. There's always another topic to grasp or rabbit hole to fall into.
Education
2 years interactive design and web development, and a further 15 years of curiosity and tinkering
Welp. JS got us on this one. The new using keyword allows for simpler handling of cleanup if there was an error that would cause memory leaks otherwise.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
async/await
are (almost) syntatic sugar for the plain-old Promise API, you could accomplish the same "blocking" behaviour usingpromise1().then(promise2).then(promise3)
and so on, thus this is not a problem withasync/await
syntax per-se, IMO.One using
await
should first know about the Promise API, so it'll know better how to use itAbsolutely, and even when knowing these tools some developers tend not to prioritize parallel executions for some reason. A colleague said the same thing as you after reading it, and it's very pertinent.
Thanks Luciano !
I would suggest you to write a post of "How to parallelize your work with async/await". There's a nice feature that is something like:
If I'm not mistaken, this way you 1) use
async/await
, what's really nice 2) let the promises run right-awayPromise chains are a problematic solution, as each '.then' produces another promise. What happens if an earlier 'then' throws and there's no catch or other error handling? Memory leak
Welp. JS got us on this one. The new
using
keyword allows for simpler handling of cleanup if there was an error that would cause memory leaks otherwise.