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

Crash when logging integer #69

Closed
Tiim opened this issue Jun 18, 2019 · 3 comments
Closed

Crash when logging integer #69

Tiim opened this issue Jun 18, 2019 · 3 comments

Comments

@Tiim
Copy link

Tiim commented Jun 18, 2019

When i directly log a number with console.log without using pino then peno-pretty crashes with the following error message:

/code/node_modules/pino-pretty/lib/utils.js:178
   if ('level' in log === false) return undefined
               ^

 TypeError: Cannot use 'in' operator to search for 'level' in 2
     at prettifyLevel (/code/node_modules/pino-pretty/lib/utils.js:178:15)
     at pretty (/code/node_modules/pino-pretty/index.js:85:29)
     at Transform.transform [as _transform] (/code/node_modules/pino-pretty/bin.js:38:18)
     at Transform._read (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_transform.js:177:10)
     at Transform._write (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_transform.js:164:83)
     at doWrite (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_writable.js:405:139)
     at writeOrBuffer (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_writable.js:394:5)
     at Transform.Writable.write (/code/node_modules/pino-pretty/node_modules/readable-stream/lib/_stream_writable.js:303:11)
     at Transform.ondata (/code/node_modules/split2/node_modules/readable-stream/lib/_stream_readable.js:662:20)
     at Transform.emit (events.js:196:13)

The following snipped in my code (fastify server) will produde this crash:

console.log(index); // index = 2
@jsumners
Copy link
Member

Looks like a Number.isFinite(log) check should be added at

if ([null, true, false].includes(log)) {

Care to submit a PR?

@Tiim
Copy link
Author

Tiim commented Jun 18, 2019

I would love to, but I don't have time at the moment.

@Tiim
Copy link
Author

Tiim commented Jun 20, 2019

Thanks #70 seems to fixed it 👍

@Tiim Tiim closed this as completed Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants