My application is being plagued by this critical error in production:
/usr/src/app/node_modules/@nestjs/common/services/console-logger.service.js:137
? `${this.colorize('Object:', logLevel)}\n${JSON.stringify(message, (key, value) => typeof value === 'bigint' ? value.toString() : value, 2)}\n`
^
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'ClientRequest'
| property 'socket' -> object with constructor 'Socket'
--- property '_httpMessage' closes the circle
at JSON.stringify (<anonymous>)
at ConsoleLogger.stringifyMessage (/usr/src/app/node_modules/@nestjs/common/services/console-logger.service.js:137:62)
at ConsoleLogger.formatMessage (/usr/src/app/node_modules/@nestjs/common/services/console-logger.service.js:130:29)
at /usr/src/app/node_modules/@nestjs/common/services/console-logger.service.js:122:43
at Array.forEach (<anonymous>)
at ConsoleLogger.printMessages (/usr/src/app/node_modules/@nestjs/common/services/console-logger.service.js:117:18)
at ConsoleLogger.error (/usr/src/app/node_modules/@nestjs/common/services/console-logger.service.js:44:14)
at Logger.error (/usr/src/app/node_modules/@nestjs/common/services/logger.service.js:34:75)
at Logger.descriptor.value (/usr/src/app/node_modules/@nestjs/common/services/logger.service.js:163:27)
at ExceptionsHandler.handleUnknownError (/usr/src/app/node_modules/@nestjs/core/exceptions/base-exception-filter.js:54:43)
I am unable to replicate this issue during development and I am unsure of its root cause. Is there a way for me to trace back to where this error originated?
Even after running with DEBUG=*
, I have not been able to pinpoint the exact source of the problem.
Based on my logs, I suspect that the error is occurring near these lines:
this.logger.error(error.toString())
throw new InternalServerErrorException(error.toString())
However, it appears that error.toString()
returns [object Object]
, which although unhelpful, may not be incorrect.