Why does the following function gets stuck when I hit it from postman? Why does the following function gets stuck when I hit it from postman? mongoose mongoose

Why does the following function gets stuck when I hit it from postman?


Basically, your code looks fine (I have only read it, not tested it!). But there might be problems when e.g. an exception is thrown synchronously. This could happen, for example, in the call to fs.unlinkSync (please note that I'm not saying there the problem is in this line, this is just an example).

If this happens, then further execution of this route is stopped, and you will never receive a result. The same could happen at other places as well, so maybe a try/catch around everything which results in sending a 500 would be a good idea.