Running an express server with route handler like this:
app.get('*', (req, res) => {
console.log('Received request');
setTimeout(() => {
res.end();
console.log('Ended request');
}, 3000);
});
If one visits the route '/foo' and then immediately '/bar' (in two different tabs), this will be output via console.log:
Received request
Received request
Ended request
Ended request
But if you do the same except visiting '/foo' in both tabs, the server waits for the first request before handling the second:
Received request
Ended request
Received request
Ended request
I believed all method requests were handled asynchronously, but this seems to be an exception. Could anyone provide an in-depth explanation on why this happens? I have not been able to find any info in the express documentation.