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

Handle complex object cases #1061

Merged
merged 1 commit into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
},
"dependencies": {
"fast-redact": "^3.0.0",
"fast-safe-stringify": "^2.0.7",
"fast-safe-stringify": "^2.0.8",
"flatstr": "^1.0.12",
"pino-std-serializers": "^3.1.0",
"quick-format-unescaped": "^4.0.3",
Expand Down
34 changes: 34 additions & 0 deletions test/complex-objects.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict'

const { test } = require('tap')
const { sink, once } = require('./helper')
const { PassThrough } = require('stream')
const pino = require('../')

test('Proxy and stream objects', async ({ equal }) => {
const s = new PassThrough()
s.resume()
s.write('', () => {})
const obj = { s, p: new Proxy({}, { get () { throw new Error('kaboom') } }) }
const stream = sink()
const instance = pino(stream)
instance.info({ obj })

const result = await once(stream, 'data')

equal(result.obj, '[unable to serialize, circular reference is too complex to analyze]')
})

test('Proxy and stream objects', async ({ equal }) => {
const s = new PassThrough()
s.resume()
s.write('', () => {})
const obj = { s, p: new Proxy({}, { get () { throw new Error('kaboom') } }) }
const stream = sink()
const instance = pino(stream)
instance.info(obj)

const result = await once(stream, 'data')

equal(result.p, '[unable to serialize, circular reference is too complex to analyze]')
})