Open flyweight opened 5 months ago
Unsure if this is purposeful, but I ran into this small issue while replacing some of my existing warning logs.
Test file:
$ cat test.mjs import pino from 'pino' const log = pino() Promise.reject("FAIL").catch(log.error);
Pino Exception:
/tmp/pino/node_modules/pino/lib/tools.js:68 if (typeof this[msgPrefixSym] === 'string' && msg !== undefined && msg !== null) { ^ TypeError: Cannot read properties of undefined (reading 'Symbol(pino.msgPrefix)') at LOG (/tmp/pino/node_modules/pino/lib/tools.js:68:22)
To get it working, you must bind the correct context:
$ cat test.mjs import pino from 'pino' const log = pino() Promise.reject("FAIL").catch(log.error.bind(log)); // OR Promise.reject("FAIL").catch(e => log.error(e));
Expected result: pino should just log the error without throwing an exception. Thanks
This is expected. Back in the days, .bind() was very expensive, so we avoided it. We would need to check if it's still the case.
Unsure if this is purposeful, but I ran into this small issue while replacing some of my existing warning logs.
Test file:
Pino Exception:
To get it working, you must bind the correct context:
Expected result: pino should just log the error without throwing an exception. Thanks