6

I thought i knew promises until today, but Promise.all and chaining really destroyed my confidence today.

Comments
  • 2
    don't believe them promises...
  • 2
    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.
  • 3
    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.
  • 2
    @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.
  • 2
    @CoreFusionX ya man async await saves lives
Add Comment