I have been running Node 0.8.25 and Express 3.4.0.
Works great.
I tried upgrading to Node 0.10 Stable and I started having strange problems.
For example, I have a route that looks (sort of) like this:
app.post( "/toPDF", auth.isAuthorized, function( req, res, next ){
getPDF( req.data, function( err, pdfData ) {
if ( err ) {
next( err );
} else {
res.setHeader( "Content-type", "application/pdf" );
res.setHeader( "Cache-Control", "no-cache" );
res.setHeader( "Accept-Ranges", "none" );
res.setHeader( "Content-Disposition", "inline; filename=stuff.pdf" );
res.end( pdfData.raw, "binary" );
}
});
});
After upgrading to Node 0.10, the first time I call this route, everything works as expected.
However the second time the route is called, the application crashes with the error "Headers already sent."
I wanted to see which headers were already present in the response. So I added the following to the top of the getPDF callback, before any headers are sent.
console.log( res._headers );
Right before it crashes, this outputs:
Content-type application/pdf
Cache-Control no-cache
Accept-Ranges none
Content-Disposition inline; filname = stuff.pdf
It looks as if my old response object is somehow hanging around? Any ideas what might be going on here?