Hello!
I try to log an object like this:
// just an object with property 'error'
var obj = { data: 'bla', error: { message: 'bla error', stack: null } }
prettyPino.info(obj)
and i get an error:
TypeError: Cannot read property 'length' of null
at filter (node_modules/pino/pretty.js:87:23)
at DestroyableTransform.mapLine [as mapper] (node_modules/pino/pretty.js:251:15)
at DestroyableTransform.transform [as _transform] (node_modules/split2/index.js:33:21)
at DestroyableTransform.Transform._read (node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (node_modules/readable-stream/lib/_stream_transform.js:172:83)
at doWrite (node_modules/readable-stream/lib/_stream_writable.js:418:64)
at writeOrBuffer (node_modules/readable-stream/lib/_stream_writable.js:407:5)
at DestroyableTransform.Writable.write (node_modules/readable-stream/lib/_stream_writable.js:334:11)
at EventEmitter.pinoWrite (node_modules/pino/pino.js:220:12)
at EventEmitter.LOG (node_modules/pino/lib/tools.js:93:10)
...
In pretty.js null is a matches for
var matches = /^(\s*"stack":)\s*"(.*)",?$/.exec(line)
'length' of null is
if (matches.length === 3) {
Please add null check
Best regards
Did this work correctly in 4.14.0?
just checked - works correctly in 4.14.0 - error introduced in 4.15.0
Ugh, I need to get the CLI revamp done.
Anyway, this can be easily fixed with a small patch, @grbr would you like to do the honors?
FYI, I have this accounted for in the upcoming separate prettifier:
https://github.com/pinojs/pino-pretty/blob/95823e330698319b567b92754894dc564b8351db/index.js#L215
https://github.com/pinojs/pino-pretty/blob/95823e330698319b567b92754894dc564b8351db/test/errorProps.test.js#L46-L60
i've added pull request
Most helpful comment
Ugh, I need to get the CLI revamp done.