title: node.js + connect 404 error
body: <p>I just started learning node.js. I have following (server) sample:</p>
  
  <pre><code>
  var app = require("express").createServer();
  app.listen(80);
  
  function fail(req, res, next) { setTimeout(next, 10); }
  function success() {
      return function(req, res, next) { setTimeout(next, 10); };
  }
  app.get("/success0", success(), function(req, res, next) { res.send("0"); });
  app.get("/success1", success(), function(req, res, next) { res.send("1"); });
  app.get("/fail0", fail, function(req, res, next) { res.send("0"); });
  app.get("/fail1", fail, function(req, res, next) { res.send("1"); });
  </code></pre>
  
  <p>If I call /fail0 and /fail1 simultaneously, one of them will succeed and the other one fails with 404 error. calling /success0 and success1 however works. Can someone enlighten me why one works and the other doesn't? Below is my testing client:</p>
  
  <pre><code>
  var http = require("http");
  var sys = require("sys");
  
  for(var i = 0; i &lt; 10; i++) {
      var io = http.createClient(80, "localhost");
      var request = io.request("GET", "/fail" + (i%2), {host:"localhost"});
      request.on("response", function(response) {
          var body = "";
          response.on("data", function(data) { body += data; });
          response.on("end", function() {
              sys.puts(response.statusCode + ":" + body);
          });
      }).end();
  }
  </code></pre>
  
  <p>running above client returns:</p>
  
  <pre>
  404:Cannot GET /fail0
  200:1
  404:Cannot GET /fail0
  200:1
  404:Cannot GET /fail0
  200:1
  404:Cannot GET /fail0
  200:1
  404:Cannot GET /fail0
  200:1
  </pre>