4 ms·
This article doesn’t have any depth. TLDR: avoid blocking unrelated async requests via await. What’s far more interesting and harder to solve ergonomically is
by bern4444 5y ago
This article doesn’t have any depth.
TLDR: avoid blocking unrelated async requests via await.
What’s far more interesting and harder to solve ergonomically is to parallelize async functions - parse responses to validate if they’ve succeeded or failed via Promise.allSettled, and then continue to work with the resolved values while retrying any failed requests.
That’s what I was hoping this would go into but unfortunately it doesn’t.
- rileymat2 5y agoYou would think this has no depth, but I have seen code like that waits in serial over and over. So clearly it is deep for the novice, which are in abundance.
- have_faith 5y agoYeah this domain of problems doesn't seem to have a "neat" solution either built in or via some defacto library. I'm guessing you want to easily be able to say "attempt these requests, retry the failures at most these times, using this method of back-off, get back to me with the result" plus whatever other options of configurability for the failure modes. If you are using ReactJS then react-query does a very good job of handling these concerns for you specifically for syncing up with server side state locally.
- Footkerchief 5y agoThe article makes a point that is both a) simple and self-evident and b) ignored by 90% of JS developers I've encountered, who are just trying to write procedural code and adding as many awaits as needed to achieve that. This is why I'm convinced that async should be opt-in, because most people don't use it effectively even when forced to acknowledge its existence.
- hinkley 5y agoI took one of these out recently and didn’t see much of an improvement. I was already fanning out a lot of requests so the sequential part was barely out of the noise floor. 5% at most. But I did have to add throttling to that request because of it. It had been previously limited by how fast the follow on request could be run. Doing more things in parallel doesn’t automatically make you faster. Every new batch of developers seems to have to learn this the hard way. Trying to do everything at once can make you more brittle. And does so, as often as not.