Thursday, 2 November 2017

No line number in error

Hi, I run an Express/Node production server - works great, but I'm getting an error where there's no meaningful line number, and I'm pulling my hair out trying to find it.The error is about sending headers after they've been sent. Yes, I know what this means, but without a line number, I can't track which res.send or res.render I need to fix.The error is as follows:0|https | Error: Can't set headers after they are sent. 0|https | at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:357:11) 0|https | at ServerResponse.header (/websites/node_modules/express/lib/response.js:730:10) 0|https | at ServerResponse.send (/websites/node_modules/express/lib/response.js:170:12) 0|https | at done (/websites/node_modules/express/lib/response.js:967:10) 0|https | at tryHandleCache (/websites/node_modules/ejs/lib/ejs.js:208:10) 0|https | at View.exports.renderFile [as engine] (/websites/node_modules/ejs/lib/ejs.js:412:10) 0|https | at View.render (/websites/node_modules/express/lib/view.js:128:8) 0|https | at tryRender (/websites/node_modules/express/lib/application.js:640:10) 0|https | at EventEmitter.render (/websites/node_modules/express/lib/application.js:592:3) 0|https | at ServerResponse.render (/websites/node_modules/express/lib/response.js:971:7) So the line numbers listed are for the Express files, but not the file where my code is (https.js).I'm currently logging to the console before each res.send and res.render, and whilst 1 line in particular is showing up, I still can't figure out where I'm res.sending/res.rendering again.This particular line is in an async.eachSeries loop, and the res.render is done at the end of the loop. So I've added a 'return false' after the res.render to stop any further loops, but the problem persists.I guess my first question would be, is the 'return false' going to kill the async loop? And is there any other way I can track down the root of the problem?Any help will be greatly appreciated!

Submitted November 02, 2017 at 05:45PM by L33-the-3rd

No comments:

Post a Comment