Skip to content
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

unsafe stringify and JSON circular structure #89

Open
nitzan-blink opened this issue May 5, 2024 · 0 comments
Open

unsafe stringify and JSON circular structure #89

nitzan-blink opened this issue May 5, 2024 · 0 comments

Comments

@nitzan-blink
Copy link

Hi,
if I pass an axios error object to the transport's .error() function, the logger crashes with the following exception:

2024-05-05 09:59:11.394  Error: app logged out: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'httpAgent' -> object with constructor 'Agent'
    |     property 'sockets' -> object with constructor 'Object'
    |     ...
    |     property 'errored' -> object with constructor 'Object'
    --- property 'config' closes the circle
2024-05-05 09:59:11.397  TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'httpAgent' -> object with constructor 'Agent'
    |     property 'sockets' -> object with constructor 'Object'
    |     ...
    |     property 'errored' -> object with constructor 'Object'
    --- property 'config' closes the circle
    at JSON.stringify (<anonymous>)
    at LogstashTransport.log (/app/node_modules/.pnpm/winston-logstash@1.2.1_winston@3.13.0/node_modules/winston-logstash/lib/winston-logstash-latest.js:34:27)
    at LogstashTransport._write (/app/node_modules/.pnpm/winston-transport@4.5.0/node_modules/winston-transport/index.js:82:19)
    at doWrite (/app/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_writable.js:390:139)
    at writeOrBuffer (/app/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_writable.js:381:5)
    at Writable.write (/app/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_writable.js:302:11)
    at DerivedLogger.ondata (/app/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js:629:20)
    at DerivedLogger.emit (node:events:529:35)
    at addChunk (/app/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js:279:12)
    at readableAddChunk (/app/node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js:262:11)

a related issue is: winstonjs/winston#1946
where it was suggested that fast-safe-stringify should be used instead of JSON.stringify().
in the code I see several refernces to stringify libs, but they are all in the test bench.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant