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

TypeError when converting circular structure to JSON.

Open jeremy-j-ackso opened this issue 5 years ago • 1 comments

There should be a strategy for dealing with circular JSON structures so that we can get some kind of logging on them.

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'TLSSocket'
    |     property 'parser' -> object with constructor 'HTTPParser'
    --- property 'socket' closes the circle
    at JSON.stringify (<anonymous>)
    at graylog.log [as _log] (/app/node_modules/graylog2/graylog.js:170:31)
    at graylog.info (/app/node_modules/graylog2/graylog.js:106:17)
    at Immediate.<anonymous> (/app/node_modules/winston-graylog2/lib/winston-graylog2.js:79:50)
    at processImmediate (internal/timers.js:456:21)

jeremy-j-ackso avatar Feb 24 '20 16:02 jeremy-j-ackso

Suggesting either a custom replacer that detects a circular reference and likely discards it or switch to util.inspect().

jeremy-j-ackso avatar Feb 24 '20 16:02 jeremy-j-ackso