Created
December 15, 2010 22:32
-
-
Save cpetzold/742719 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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