-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.0.0-rc3] Logging object with circular references breaking #1248
Comments
Tricky! What would you expect it to log for a circular object? |
Maybe the same behaviour as 2.4 or at least not breaking the logging pipe. The problem is that some of the error thrown by some lib contains circular properties. |
Maybe the way that util does it have |
Maybe use of https://github.com/moll/json-stringify-safe or https://github.com/davidmarkclements/fast-safe-stringify is an appropriate solution? |
This may be arguable the more important point -- I ran into a case where a formatter threw an exception and all subsequent log attempts quietly failed. An edge-case failure in logging a message should not halt all logging 😟 Is that expected behavior? |
Agreed -- seems like the first thing to do is to figure out how to make things more robust so any bad log call doesn't break any future logs. (This should probably be true for all transports, so some change in |
@DABH I have been unable to find which layer is swallowing the errors and breaking the logging pipeline. I'm happy to dig in and try to come up with a viable solution for that, but I'll need an assist on finding the root cause. Do you want to track the "error robustness" in a separate issue? I feel that solving circular references is also important to solve and should be addressed separately. Edit: Opened #1261 to cover robustness |
@Danlevan It looks like the root cause of the failure to serialize is actually in the You probably want to open an issue there for this -- once it has been solved in the lib, the dependencies will just need to be updated here. |
@crussell52 @Nokel81 @Danlevan removing built-in, default always on support for logging of circular object references was a conscious performance decision for the default This problem is 100% solvable as a custom format – here's a quick & dirty one. If you'd like to contribute one to const cycle = require('cycle');
const { format } = require('winston');
const { combine, json } = format;
// Create a format to decycle the object
const decycleFormat = format((info, opts) => cycle.decycle(info))
// Combine the decycleFormat with the built-in json format.
const circularJsonFormat = combine(
decycle(),
json()
); |
FYI circular JSON is supported by default thanks to winstonjs/logform#35 |
v3.0.0-rc3
When logging data with circular data, it does not log and subsequent logs are not logged neither
The text was updated successfully, but these errors were encountered: