devoidfury / express-debug

Debug toolbar middleware for developing applications in express (node.js)
Other
199 stars 16 forks source link

fixup: res.render(view, opts, callback), callback broken #18

Open pjincz opened 9 years ago

pjincz commented 9 years ago

I have reviewed the code, line 91-94 is not necessary at all, and it break res.render callback.

devoidfury commented 9 years ago

That code is meant to prevent rendering the toolbar multiple times, and only when the request is expecting HTML and is not ajax -- what error are you getting, can you provide a test case?

pjincz commented 9 years ago

Hi friend, Thank you for your reply. Here is a demo to reproduce:

// app.js

var express = require('express');
var app = express();

app.get('/', function(req, res) {
  console.log(req.headers.accept);
  res.render('index.jade', function (err, data){
    res.send(data.replace('kitty', 'world'));
  });
});

require('express-debug')(app);
app.listen(3000);

// views/index.jade

h1 hello kitty

// dependency: express, jade, express-debug

Then, in access http://127.0.0.1:3000, got hello world, it's OK.

Try

$ curl 127.0.0.1:3000
<h1>hello kitty</h1>
# wrong result, result sent around callback