gelf-stream
gelf-stream copied to clipboard
'flatten' function leads to a stack overflow on circular reference
Hi!
When the 'flatten' function try to flatten a circular reference, it try to flatten until a stack overflow occurs. I see 3 solutions to solve that problem:
- Limit flattening to a defined level (pretty easy)
- Look for circular references (a bit harder)
- Ask people to not log circular references
Tell me if you prefer a solution. I can make a PR if you want.
Is this using the provided Bunyan mapper with forBunyan
? If so, you can provide your own mapping function:
var GelfStream = require('gelf-stream').GelfStream
var stream = new GelfStream(host, port, {map: myMappingFunction})
See how this is done in the source: https://github.com/mhart/gelf-stream/blob/master/gelf-stream.js#L117-L119
(or you could just get rid of any circular references before logging)
Yes, I use forBunyan
.
Of course, it is a solution if you do not want an evolution.
I do not see a way to get rid of that circular reference occuring in the response object of restify which is logged at trace level.
Thanks for your quick advice.