I did some experiment with node earlier
The following code outputs "aaa" to console, and the browser keeps waiting for response, as expected.
var http = require("http");
http.createServer(function (req, res) {
//res.writeHead(200);
console.log("aaa");
//res.end("hello");
//console.log("test111");
//res.end("bye");
}).listen(5555);
Output:
aaa
But, as soon as I un-comment the first res.end, node writes "aaa" to the console twice on one request!
var http = require("http");
http.createServer(function (req, res) {
res.writeHead(200);
console.log("aaa");
res.end("hello");
//console.log("test111");
//res.end("bye");
}).listen(5555);
Output:
aaa
aaa
Finally, when I un-comment everything,
var http = require("http");
http.createServer(function (req, res) {
res.writeHead(200);
console.log("aaa");
res.end("hello");
console.log("test111");
res.end("bye");
}).listen(5555);
Output:
aaa
test111
aaa
test111
Any idea why the console.log statements are executed twice per single request?