Skip to content

Instantly share code, notes, and snippets.

@cpetzold
Created December 15, 2010 22:32
Show Gist options
  • Save cpetzold/742719 to your computer and use it in GitHub Desktop.
Save cpetzold/742719 to your computer and use it in GitHub Desktop.
// This code, run with 10 concurrent users hitting both routes, results in /1 failing with a 404 at a rate ~50%
var express = require('express');
var app = express.createServer();
app.configure(function(){
app.use(app.router);
});
function mw(req, res, next) {
setTimeout(function(){
next();
}, 100);
}
app.get('/1', mw, function(req, res){
res.send(200);
});
app.get('/2', mw, function(req, res){
res.send(200);
});
app.listen(80);
// As a sanity check, this works
var express = require('express');
var app = express.createServer();
app.configure(function(){
app.use(app.router);
});
function mw(req, res, next) {
setTimeout(function(){
next(req, res);
}, 100);
}
app.get('/1', function(req, res){
mw(req, res, function(req, res){
res.send(200);
});
});
app.get('/2', function(req, res){
mw(req, res, function(req, res){
res.send(200);
});
});
app.listen(80);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment