News for hackers. Stuff that matters.
Re:Code optimizations when using async/await by slaymaker1907 on Tuesday January 04, 2022 @12:16PM (#29797180)
Correct me if I'm wrong, but I think you can avoid this by doing:

thingToUseLater.catch(() => {})

And just ignoring the result of .catch(). Promises are reusable so thingToUseLater can be waited on later when you want to block for it.

Thanks for thoughts on this. I use promises a lot but this is an edge case I hadn't thought about. They are really pretty handy for build scripts since they make your dependencies explicit.

Re:Code optimizations when using async/await by beardedetim on Tuesday January 04, 2022 @05:19PM (#29801433)
Yup. If you call catch, you've handled the promise. You would need to throw from within the callback in order for the promise itself to reject after that.