express-debug icon indicating copy to clipboard operation
express-debug copied to clipboard

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

Open pjincz opened this issue 10 years ago • 2 comments

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

pjincz avatar Jul 03 '15 05:07 pjincz

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?

devoidfury avatar Jul 03 '15 20:07 devoidfury

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

pjincz avatar Jul 06 '15 08:07 pjincz