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

Logging Error-like object causes crash #505

Closed
aqemi opened this issue Apr 24, 2024 · 0 comments · Fixed by #506
Closed

Logging Error-like object causes crash #505

aqemi opened this issue Apr 24, 2024 · 0 comments · Fixed by #506

Comments

@aqemi
Copy link
Contributor

aqemi commented Apr 24, 2024

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) {

aqemi added a commit to aqemi/pino-pretty that referenced this issue Apr 24, 2024
aqemi added a commit to aqemi/pino-pretty that referenced this issue Apr 24, 2024
aqemi added a commit to aqemi/pino-pretty that referenced this issue Apr 24, 2024
aqemi added a commit to aqemi/pino-pretty that referenced this issue Apr 24, 2024
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

Successfully merging a pull request may close this issue.

1 participant