pino
semver
>=7.0.0 <12.0.0postconditions10functions7last verified2026-04-03coverage score71%Postconditions — what we check
- pino · destination-errorerrorWhenThe destination stream emits an error event and no error handler is attachedThrows
Unhandled error event crashes the Node.js processRequired handlingCaller MUST attach an error handler to custom destination streams. Use destination.on('error', handler) before passing to pino. pino.destination() streams are async-friendly but still emit errors on disk full, permissions, etc.costhighin prodimmediate exceptionusers seeservice unavailablevisibilitycatastrophicSources[1] - pino · invalid-levelerrorWhenAn invalid log level string is passed to pino() options.levelThrows
Error: unknown level valueRequired handlingCaller MUST use valid level strings: 'trace', 'debug', 'info', 'warn', 'error', 'fatal', 'silent'. Invalid levels throw synchronously during logger construction.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilitycatastrophicSources[1] - child · child-bindings-serializer-errorerrorWhenA serializer applied to child bindings throws during child logger creation or first useThrows
Error from the serializer functionRequired handlingCaller MUST ensure serializers passed in child() bindings do not throw. Errors in child binding serializers propagate to the caller of child() or the first log call.costmediumin prodimmediate exceptionusers seedegraded performancevisibilitysilentSources[1] - transport · transport-error-event-unhandlederrorWhenThe transport worker thread emits an 'error' event and no error listener is attached to the returned ThreadStream.Throws
Unhandled 'error' event crashes the Node.js process with an uncaught exception. This occurs when: (1) the transport worker thread crashes, (2) the worker process exits unexpectedly, (3) an unhandled rejection occurs inside the worker.Required handlingCaller MUST attach an error handler to the transport stream before passing it to pino(): const transport = pino.transport({ target: './my-transport' }); transport.on('error', (err) => { console.error('transport error:', err); process.exit(1); }); Per pino documentation: transport errors are NOT recoverable — terminate the process.costhighin prodimmediate exceptionusers seeservice unavailablevisibilitycatastrophic - transport · transport-module-not-founderrorWhenThe transport target module cannot be resolved (module not installed, wrong path, or typo in the target string).Throws
Error thrown synchronously at pino.transport() call time: "unable to determine transport target for \"<target-string>\"" or Node.js MODULE_NOT_FOUND error from require() resolution failure.Required handlingCaller MUST ensure the transport target is installed and the path/package name is correct. Catch the synchronous throw at startup: try { const transport = pino.transport({ target: 'pino-pretty' }); } catch (err) { console.error('Failed to start transport:', err.message); process.exit(1); }costmediumin prodimmediate exceptionusers seeservice unavailablevisibilitycatastrophicSources[3] - transport · transport-target-targets-conflicterrorWhenBoth 'target' and 'targets' options are provided simultaneously to pino.transport().Throws
Error: "only one of target or targets can be specified" Thrown synchronously at pino.transport() call time.Required handlingUse either 'target' (single transport) or 'targets' (multi-transport array), never both.costlowin prodimmediate exceptionusers seeservice unavailablevisibilitycatastrophicSources[3] - destination · destination-write-error-eventerrorWhenThe SonicBoom destination stream encounters a write error (disk full, EACCES, EPERM, ENOENT on file path, fd closed) and no error listener is attached.Throws
Unhandled 'error' event crashes the Node.js process. SonicBoom emits 'error' events on file open failure, write failure, and close failure — it never throws synchronously on write (to preserve throughput), but unhandled error events crash the process.Required handlingCaller MUST attach an error handler to the destination before use: const dest = pino.destination({ dest: '/var/log/app.log', sync: false }); dest.on('error', (err) => { console.error('log destination error:', err); // decide: fallback to stdout? terminate? alert ops? }); const logger = pino(dest);costhighin prodimmediate exceptionusers seeservice unavailablevisibilitycatastrophicSources[4] - flush · flush-callback-error-ignoredwarningWhenlogger.flush(cb) is called with a callback but the callback ignores the error parameter, OR flush is called without a callback and the underlying write fails.Throws
The callback is invoked with an Error object when the underlying stream flush fails (e.g., disk full, destination closed, EBADF). If no callback is provided and the flush fails, the error is silently swallowed (noop is used as the callback).Required handlingWhen flush correctness matters (e.g., graceful shutdown), always check the callback error: logger.flush((err) => { if (err) { console.error('flush failed:', err.message); // handle: retry, alert, or accept log loss } process.exit(0); });costlowin prodsilent failureusers seedegraded performancevisibilitysilent - multistream · multistream-invalid-stream-entryerrorWhenAn entry in the streams array does not implement the DestinationStream interface (missing write() method) or is not a valid StreamEntry object.Throws
Error: "stream object needs to implement either StreamEntry or DestinationStream interface" Thrown synchronously when the invalid entry is added via multistream() or add().Required handlingEnsure each stream entry has a write(msg: string): void method. Use pino.destination(), fs.createWriteStream(), or process.stdout directly.costlowin prodimmediate exceptionusers seeservice unavailablevisibilitycatastrophicSources[6] - multistream · multistream-individual-stream-failure-silentwarningWhenOne stream in a multistream configuration throws during write() (e.g., a SonicBoom stream destination has become invalid) while other streams are healthy.Throws
The write error from the failing stream propagates synchronously through multistream's write() function, which has no try-catch. This can drop log lines to ALL streams (not just the failing one) since write() aborts on first error.Required handlingWrap individual streams with error handling or use streams that emit 'error' events rather than throwing. Monitor individual destination health separately. Consider using pino.transport() with multiple targets instead — transports run in worker threads and isolate write failures from the main thread.costmediumin prodsilent failureusers seedegraded performancevisibilitysilentSources[6]
Sources
Every postcondition cites at least one of these. Numbered to match the footnotes above.
- [1]github.com/pinojs/pinohttps://github.com/pinojs/pino/blob/main/docs/api.md
- [2]raw.githubusercontent.com/pinojs/pinohttps://raw.githubusercontent.com/pinojs/pino/main/docs/transports.md
- [3]github.com/pinojs/pinohttps://github.com/pinojs/pino/blob/main/lib/transport.js
- [4]github.com/mcollina/sonic-boomhttps://github.com/mcollina/sonic-boom
- [5]github.com/pinojs/pinohttps://github.com/pinojs/pino/blob/main/lib/proto.js
- [6]github.com/pinojs/pinohttps://github.com/pinojs/pino/blob/main/lib/multistream.js
Need a different package?
Request a profile