visionmedia/express — Issue #893: Middlewares are blocking each other
Author: taris
Created: 2011-11-16 10:11:09+00:00
State: open

Either i am missing something here or any middleware in express is blocking the middleware that follows.

Example:

```js
var express = require('express');
var app = express.createServer();
var util = require('util');

app.use(
function () {
util.log('--- custom middleware ---');
},
express.logger()
);

app.get('/', function(req, res){
res.send('Hello World');
});

console.log('Port: 3000');
app.listen(3000);
```

Execute that script, open up http://localhost:3000 with your browser and you will see in your console an new line containing something like:

```js
- --- custom middleware ---
```

But there is no line generated by the logger() middleware of express. When you turn them around (first logger(), then the custom middleware) then you will see in your console an apache access.log style entry but no "custom middleware" after that.

I discovered the same behaviour with the combination of logger() and bodyParser().

```js
var express = require('express');
var app = express.createServer();
var util = require('util');

app.use(
express.bodyParser(),
express.logger()
);

app.post('/', function(req, res){
res.end('viewing user ' + req.body.user.name);
});

console.log('Port: 3000');
app.listen(3000);
```

Do i have to call them otherwise?