What is the point of doing setTimeout(fx, 0)
in node?
This is not asynchronous or even non-blocking, as the async function is really the setTimeout
, not your fx
, and after setTimeout
has run asynchronously, you will end up running fx
which will block your code anyway.
Doing the setTimeout
with 0
to call a function fx
will just wait until the stack is empty to run fx
, but then while fx
is running you won't be able to accept any requests, right?
So is setTimeout(fx, 0)
just a way of telling node 'hey, run this whenever you can'? Is there any way to trully run async functions in Node?