bithavoc / express-winston

express.js middleware for winstonjs
https://www.npmjs.com/package/express-winston
MIT License
797 stars 187 forks source link

Uncaught error. TypeError: Cannot convert undefined or null to object in express-winston 2.1.1 #130

Closed jamiemjennings closed 7 years ago

jamiemjennings commented 7 years ago

Hitting the following error with express-winston v2.1.1 when res.body is an empty array []. This problem did not occur with express-winston v2.1.0.

Uncaught error. TypeError: Cannot convert undefined or null to object
  at ServerResponse.res.end (/usr/src/app/node_modules/express-winston/index.js:257:31

The problem appears to be here: https://github.com/bithavoc/express-winston/pull/129/files#diff-168726dbe96b3ce427e7fedce31bb0bcR257

ie. delete logData.req.body;

rosston commented 7 years ago

Do you by chance have an empty requestWhitelist? That seems like the only way this bug could have happened.

rosston commented 7 years ago

My (hopeful, but very likely) fix is released in 2.1.2. Feel free to comment here or open a new issue if that doesn't fix your problem.

jamiemjennings commented 7 years ago

@rosston: thanks for the quick response. Yes this would be with an empty requestWhitelist. I'll test 2.1.2 to confirm the fix.

jamiemjennings commented 7 years ago

@rosston: the fix works! Thanks again