pinojs / pino-pretty

🌲Basic prettifier for Pino log lines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logging Error-like object causes crash

aqemi opened this issue · comments

Logging Error-like object causes crash

index.js file

const logger = require('pino')();
logger.error({type: 'Error', stack: ['any']});

will not log this item and if do several logs the process will end up with error:

node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:952:11)
    at Socket._write (node:net:964:8)
    at writeOrBuffer (node:internal/streams/writable:447:12)
    at _write (node:internal/streams/writable:389:10)
    at Writable.write (node:internal/streams/writable:393:10)
    at console.value (node:internal/console/constructor:304:16)
    at console.log (node:internal/console/constructor:379:26)
    at log (/Users/spd/node_modules/nodemon/lib/utils/log.js:34:15)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Command to run:
nodemon index.js | pino-pretty

There is some code that may prevent logging of such objects:

if (log.type === 'Error' && log.stack) {