Giter VIP home page Giter VIP logo

express-crash's People

Contributors

qur2 avatar

Watchers

 avatar  avatar

express-crash's Issues

"Can\'t set headers after they are sent."

Hi. Not sure if you maintain this repo, but I have an issue:

Code:

var handle404 = function(err,req,res,next) {
    if (err) { console.log('404 handling error: '+err); }
    res.render('error.html', {code:404});
};
var handle500 = function(err,req,res,next) {
    if (err) { console.log('500 handling error: '+err); }
    res.render('error.html', {code:500});
};
app.use(crash.handle404(handle404));
app.use(crash.handle500(handle500));
crash.trapRoute(app);
crash.handle(app, handle404, handle500);

Result:

404 handling error: NotFoundError: Not found error                                                                           
_http_outgoing.js:344                                                                                                        
    throw new Error('Can\'t set headers after they are sent.');                                                              
    ^                                                                                                                        

Error: Can't set headers after they are sent.                                                                                
    at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)                                                   
    at ServerResponse.header (/home/ubuntu/workspace/node_modules/express/lib/response.js:718:10)                            
    at ServerResponse.contentType (/home/ubuntu/workspace/node_modules/express/lib/response.js:551:15)                       
    at ServerResponse.send (/home/ubuntu/workspace/node_modules/express/lib/response.js:138:14)                              
    at res.render.done (/home/ubuntu/workspace/node_modules/express/lib/response.js:957:10)                                  
    at /home/ubuntu/workspace/node_modules/nunjucks/src/environment.js:22:23                                                 
    at RawTask.call (/home/ubuntu/workspace/node_modules/nunjucks/node_modules/asap/asap.js:40:19)                           
    at flush (/home/ubuntu/workspace/node_modules/nunjucks/node_modules/asap/raw.js:50:29)                                   
    at nextTickCallbackWith0Args (node.js:420:9)                                                                             
    at process._tickCallback (node.js:349:13) 

I think somehow next() is being called, and the Can't set headers error is thrown by express's default error handler. Or am I doing something wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.