KyleRoss / node-lambda-log

Basic logging mechanism for Node.js Lambda Functions and other AWS services, which produces logs in JSON format for easier reading through Cloudwatch Logs.
https://lambdalog.dev
MIT License
193 stars 16 forks source link

incompatible with mongoose: ValidationError has a read-only toJSON function #61

Closed zoli-kasa closed 3 years ago

zoli-kasa commented 3 years ago

What happens?

TypeError: Cannot assign to read only property 'toJSON' of object 'ValidationError: XXXXXX' at Function.stubError (\node_modules\lambda-log\lib\LogMessage.js:231:16) at LogMessage.get meta [as meta] (\node_modules\lambda-log\lib\LogMessage.js:112:32) at LogMessage.get value [as value] (\node_modules\lambda-log\lib\LogMessage.js:174:15) at LogMessage.toJSON (\node_modules\lambda-log\lib\LogMessage.js:206:27) at LambdaLog.log (\node_modules\lambda-log\lib\LambdaLog.js:156:36) ...

What were you expecting to happen?

not to throw an error ...

Steps to reproduce

  1. Define a read-only toJSON function on an error object
  2. Try to log it as metadata

Environment

Operating System: ubuntu+windows10 Node Version: 14.17 Lambda Log Version: 3.0.1

KyleRoss commented 3 years ago

@zoli-kasa This has been resolved in v3.0.2 which has been published to NPM. Thanks for reporting!