When writing a web server application with node.js it is of course very important to never block the main thread. But what if a server request needs to do calculations that will take some time to complete?
Will doing a
setTimeout(myCalculationFunc(), 0);
be the best way of keeping the server responding to other requests?
I created as simple example using child_process to do heavy calculating if you would like to use it.
You can do it like this:
Calculate.js: