DEV Community

Discussion on: The dangers of async/await

Collapse
 
christopherkade profile image
Christopher Kade

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.

Thanks Luciano !

Collapse
 
lucis profile image
Lucis

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:

const p1 = promise1()
const p2 = promise2()
const r1 = await p1
const r2 = await p2

If I'm not mistaken, this way you 1) use async/await, what's really nice 2) let the promises run right-away

Thread Thread
 
acce profile image
Lawrence tranter

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

Thread Thread
 
acce profile image
Lawrence tranter

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.