Tuesday 30 June 2020

Huge oversight

A few days ago i had commented on a post asking about aync/await vs. promises. I admit the argument got a little heavy but anyway the point I was arguing about await being blocking missed a tiny detail I forgot to mention that you would have to wrap your scope in (async ( )=>{ })(). I never implied that it would be blocking your main thread, but it would how ever block the scope of the (req, res)=>{ } callback, because the entire callback would be async since there is no other body except the async lambda. Then if you were to call console.log('1'); await doSomethingAsync(); // for(...i < 100...){}console.log('2') Console.log('3') you would get 1 2 3 instead of 1 3 2. Tiny detail I missed way after the fact, but ehh.

Submitted July 01, 2020 at 12:01AM by IroncladFool597

No comments:

Post a Comment