loggly / winston-loggly-bulk

A Loggly transport for winston
https://www.loggly.com/docs/node-js-logs/
MIT License
39 stars 30 forks source link

Circular JSON structure crash #64

Closed renanccastro closed 3 years ago

renanccastro commented 4 years ago

Hello, everyone. We are using this library to push logs to loggly with Winston and Meteor, but some circular JSON structure is crashing our servers from time to time. Any clues on what could be done on the library level to avoid this?

This is some of the logs we have:

2020-06-24 11:54:30-03:00Error: Unspecified error from Loggly: TypeError: Converting circular structure to JSON
wwzj4
2020-06-24 11:54:30-03:00 --> starting at object with constructor 'Error'
wwzj4
2020-06-24 11:54:30-03:00 --- property 'note' closes the circle
wwzj4
2020-06-24 11:54:30-03:00 at /app/bundle/programs/server/npm/node_modules/meteor/pathable-logs/node_modules/node-loggly-bulk/lib/loggly/client.js:204:18
wwzj4
2020-06-24 11:54:30-03:00 at Request._callback (/app/bundle/programs/server/npm/node_modules/meteor/pathable-logs/node_modules/node-loggly-bulk/lib/loggly/common.js:209:15)
wwzj4
2020-06-24 11:54:30-03:00 at Request.self.callback (/app/bundle/programs/server/npm/node_modules/meteor/pathable-logs/node_modules/request/request.js:185:22)
wwzj4
2020-06-24 11:54:30-03:00 at Request.emit (events.js:311:20)
wwzj4
2020-06-24 11:54:30-03:00 at Request.EventEmitter.emit (domain.js:482:12)
wwzj4
2020-06-24 11:54:30-03:00 at Request.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/pathable-logs/node_modules/request/request.js:1154:10)
wwzj4
2020-06-24 11:54:30-03:00 at Request.emit (events.js:311:20)
wwzj4
2020-06-24 11:54:30-03:00 at Request.EventEmitter.emit (domain.js:482:12)
wwzj4
2020-06-24 11:54:30-03:00 at IncomingMessage.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/pathable-logs/node_modules/request/request.js:1076:12)
wwzj4
2020-06-24 11:54:30-03:00 at Object.onceWrapper (events.js:417:28)
wwzj4
2020-06-24 11:54:30-03:00 at IncomingMessage.emit (events.js:323:22)
wwzj4
2020-06-24 11:54:30-03:00 at IncomingMessage.EventEmitter.emit (domain.js:482:12)
wwzj4
2020-06-24 11:54:30-03:00 at endReadableNT (_stream_readable.js:1204:12)
wwzj4
2020-06-24 11:54:30-03:00 at processTicksAndRejections (internal/process/task_queues.js:84:21)

Thanks for the help!

Katulus commented 4 years ago

Hello @renanccastro, it looks that the object you are sending through the library contains circular reference and when it's being converted to JSON string it throws this error.

Can you figure out if it's throwing this error for some specific log statements?

renanccastro commented 4 years ago

Sorry, we can't identify exactly the log with the error. It seems like the library could get some safety wrap around the arguments, so it doesn't happen. What do you think? Or at least catch and warn about it instead of throwing the error. Would a PR be welcome?

Katulus commented 4 years ago

Sure, since you can reproduce the issue feel free to create a PR and we'll check it and merge if it's OK.

susilm commented 3 years ago

Closing as we were unable to reproduce, please reopen if issue still exists.