Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I always thought Promise.all should be Promise.allSettled and viceversa.
I found chaining easier to reason about when you realize doing a .then/.catch/.finally simply returns *another* promise which can be insta resolved or rejected. (If the body is sync or the previous promise threw).
All in all, just doing async/await does away with most such problems. -
Promises are executed parallel and potentially out of order (except when chained). That makes it hard to reason about the application state at their execution. But apart from this problem inherent to concurrency in general, promises and especially promise chaining are pretty good and powerful tools. Use them wisely.
-
@Oktokolo
If this is about Js, as I believe it is, promises all run in a single thread. Async, but never concurrent.
What you said is still perfectly valid for actual concurrent languages, tho.
I thought i knew promises until today, but Promise.all and chaining really destroyed my confidence today.
rant