-
Notifications
You must be signed in to change notification settings - Fork 116
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
customProps causes TypeError: logger[stringifySym] is not a function #312
Comments
Seems to be solved in 8.6.0 |
This is not resolved in version 8.6.0 |
I'm using pino with nestjs. Upgrade to 8.6.0 solved the issue on my end. 🤷♂️ |
I too am using pino with nestjs and updating to 8.6.0 did not solve the problem |
Thanks for reporting! Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that. |
Can confirm this occurs with latest edit: It seems to occur when the base logger is instantiated in a separate package. |
Right, of course. Here: https://github.com/pinojs/pino/blob/master/lib/symbols.js
Here is a repro. TEMPDIR=$(mktemp -d)
cd $TEMPDIR
mkdir logger
mkdir server
cat <<EOF > logger/package.json
{
"name": "logger",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"author": "",
"dependencies": {
"pino": "^8.17.2"
}
}
EOF
cat <<EOF > server/package.json
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"author": "",
"scripts": { "go": "node index.js" },
"dependencies": {
"express": "^4.18.2",
"pino-http": "^9.0.0"
}
}
EOF
cat <<EOF > logger/index.js
import pino from 'pino'
class Logger {
constructor() {
this.logger = pino({})
}
pino = () => this.logger
}
const logger = new Logger()
export default logger
EOF
cat <<EOF > server/index.js
import logger from 'logger'
import pinohttp from 'pino-http'
import http from 'http'
import express from 'express'
const app = express()
app.use(pinohttp({logger: logger.pino(), customProps: (req, res) => ({ ip: req.ip })}))
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(31337, '127.0.0.1', () => {
const req = http.request({port: 31337, host: '127.0.0.1'})
req.end()
}).close()
EOF
cd logger
npm install
cd ../server
npm install -S ../logger
npm run go || true
rm -rf $TEMPDIR |
Yes, this is on purpose.
Essentially, you are flagging a bug in your monorepo software ;). |
I think the solution to this bug is to support an optional parameter that allows a user to override the version of pino that it needs to be using. Alternatively, we could expose |
Right. We're in the
If you take a detailed look at the repro, there is only one version of |
@nuzayets I am facing the same issue. Were you able to figure out a workaround ? |
Pinned an older version without the broken PR. |
I solved my problem this way, I had the dependencies updated incorrectly. I once again, carefully and manually added the dependencies I needed and watched the yarn lock changes - the problem was solved |
I had been using |
We have the same issue with |
the problem with pino@9 and pino-http@10 is out and it should work better. The solution for this really is to remove the use of the private symbol: Line 106 in bccda3c
|
We are also facing the same issue using the latest version of |
I have same issue with |
customProps
option is causing application to crash withAfter doing some debugging, seems that
pino.child(bindings)
call returns child logger which doesn't contain most of the symbols, includingSymbol(pino.stringify)
.You can see this by:
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)
I was testing with pino 8.16.2 and pino-http 8.5.1
The text was updated successfully, but these errors were encountered: