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

Response body whitelist or filter does not work if you call end() directly

Open kjjgibson opened this issue 6 years ago • 1 comments

If you use res.write(data) and then res.end() then you won't get any response body in your logs as Winston is just patching the end method (which doesn't have the data passed to it). In this case you'll end up with an undefined body on the response.

Simple solution is to switch to .send() or .json() (which call end(chunk) under the covers) I guess but in my case I was using another library that does not do this.

I don't have a suggestion for a fix right now but a heads up to others who may experience the same problem.

kjjgibson avatar Feb 01 '19 14:02 kjjgibson

I'm pretty sure I'm also running into this - with apollo-server-express - see https://github.com/apollographql/apollo-server/blob/422609e62117ac371cd753312040a9a3add833a9/packages/apollo-server-express/src/expressApollo.ts#L47

Actually, is this related to https://github.com/bithavoc/express-winston/pull/120 ?

grantwwu avatar Feb 05 '19 21:02 grantwwu