The Problem: If I comment out the express['static'] line, the code runs perfectly. If I include it (or change the order), the app hangs for a while before responding.
To Recreate: Run the app, load up a browser and go to 127.0.0.1:51783 Refresh the page constantly (or use curl), the console will give you an output similar to:
GET / 1 ms
Then, when the timeout kicks in and the 15 requests are sent, the server becomes unresponsive and you get the following:
Server Now Unresponsive but requests queued
GET / 35549 ms
app.js
var http = require('http');
var express = require('express');
var app = express.createServer();
app.use(express.logger({ format: '\x1b[1m:method\x1b[0m \x1b[33m:url\x1b[0m :response-time ms' }));
app.use(express.bodyParser());
app.use(express['static'](__dirname + '/')); //Comment me and all works perfectly!
app.listen(51783);
http.globalAgent.maxSockets = 500; //doesn't help
setTimeout(function(){
console.log('Server Now Unresponsive but requests queued');
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15].forEach(function(item){
http.request({host:'http://cnn.com', port:80, path:'/null', method:'GET'}, function(res){
}).on('error', function(e){});
});
},5000);