Use ExpressJS app via FastCGI Use ExpressJS app via FastCGI express express

Use ExpressJS app via FastCGI


You won't do mistakes like that if you lint your code, run under strict mode, and don't use global variables like that.

Also in nodejs web applications you generally want to make the server stateless and keep all the data in the databases. This would also make it a more scalable architecture.

In applications that are security super important, you can throw heavy fuzzy testing at it to find problems like that too.

If you do all this, plus having a strict code review process, you won't have to worry about it at all.

FastCGI doesn't prevent this problem as a single or a few connections is used to communicate with the server that processes the requests(node.js in this case) and HTTP connections are multiplexed through it. A node.js process will handle multiple requests at a time.

You can potentially somehow make a solution that launches a thread but it'll be a lot slower. In case if you are using node.js for things that are required to be have high reliability or can't afford small mistakes(for example health related devices), node.js is the wrong platform for it.