pino-http: customProps causes TypeError: logger[stringifySym] is not a function
customProps
option is causing application to crash with
TypeError: logger[stringifySym] is not a function
/Users/xxxx/node_modules/pino-http/logger.js:106
const customPropBindingStr = logger[stringifySym](customPropBindings).replace(/[{}]/g, '')
After doing some debugging, seems that pino.child(bindings)
call returns child logger which doesn’t contain most of the symbols, including Symbol(pino.stringify)
.
You can see this by:
const logger = pino(pinoOptions);
console.log({logger})
const child = logger.child({});
console.log({child})
Internally pino-http does create child logger and stringify symbol is expected to be included later in the logger (https://github.com/pinojs/pino-http/blob/master/logger.js#L106)
if (customPropBindings) {
const customPropBindingStr = logger[stringifySym](customPropBindings).replace(/[{}]/g, '')
const customPropBindingsStr = logger[chindingsSym]
if (!customPropBindingsStr.includes(customPropBindingStr)) {
log = logger.child(customPropBindings)
}
}
I was testing with pino 8.16.2 and pino-http 8.5.1
About this issue
- Original URL
- State: open
- Created 7 months ago
- Comments: 15 (3 by maintainers)
Right. We’re in the
pino-http
repo here. The bug is in #288 using these symbols to reference props set in another realm, not inpino
for choosing to export unique symbols. Ifpino-http
used these imported symbols to set props and then access them, all would be fine. Instead it is accessing props with a Symbol that it has no guarantee exists on the obj.pino-http
is a separate package that interacts withpino
through exports …If you take a detailed look at the repro, there is only one version of
pino
. We’re in the same runtime. It’s not like we’re instantiatingpino
in another instance ofnode
and expecting to somehow RPC over to it. We’re in the same process, same address space, same bits on disk. How do you even see that (‘choosing which pino’) working? We only import one.Yes, this is on purpose.
Essentially, you are flagging a bug in your monorepo software 😉.
I had been using
pino@v8.19.0
andpino-http@v9.0.0
for a while without any issues and started experiencing this after bumping topino@v9.0.0
. I’m not entirely sure I understand why the previous combination of versions worked (since the proposed solution here is to pinpino-http
on an older version). I’m resorting to pinningpino
to the old version for now.@nuzayets I am facing the same issue. Were you able to figure out a workaround ?
I’m using pino with nestjs. Upgrade to 8.6.0 solved the issue on my end. 🤷♂️