Problem: If I comment out the line express ['static'], the code will work fine. If I turned it on (or reordered), the application freezes for a while before responding.
Re-creation: Launch the application, load the browser and go to 127.0.0.1ל1783 Refresh the page constantly (or use curl), the console will give you a result similar to:
GET / 1 ms
Then, when a timeout is sent and 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 + '/'));
source share