question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Missing stack trace of thrown error in log produced by nestjs built-in error handler

See original GitHub issue

[x] I’ve read the docs of nestjs-pino

[x] I’ve read the docs of pino

[x] I couldn’t find the same open issue of nestjs-pino

There is an open issue https://github.com/iamolegga/nestjs-pino/issues/535, but that issue focuses on express, but I am not convinced my issue is related to express.

What is the current behavior? nestjs-pino@2.3.0 is missing stack traces

What is the expected behavior? Stack traces should be included in error logs, just like previously in nestjs-pino@1.4.0

Please provide minimal example repo. Without it this issue will be closed I created two NestJS applications, older one includes stack traces in error logs, newer version does not.

See examples here: https://github.com/raidokaldma/nestjs-pino-issue

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
iamoleggacommented, Nov 19, 2021

shipped in v2.3.1

3reactions
iamoleggacommented, Nov 18, 2021

Finally found the bug. Working on fixing it.

In short, there is a difference between nestjs built-in LoggerService interface in v7 and v8. v7’s error method has stack argument, but in v8 it’s dropped for consistency between all the other methods. But in many places of the nestjs sources it’s still called like in v7, so this becomes a headache for lib owners to detect if optionalParams contains stack to properly set such field when logging error 😅

This issue differs from #535 because here the reason is a difference between logger versions and the logger call in exception handlers, and #535 is about request completed/errored pino-http’s log

Read more comments on GitHub >

github_iconTop Results From Across the Web

[FEATURE REQUEST] Correct stack trace in `request errored ...
A small update, stack should be fixed in the latest release for logs produced by nestjs built-in error handlers (more on this here...
Read more >
Best Practices for Node.js Error-handling - Toptal
This article will introduce you to error-handling in Node.js and demonstrate some of the best ... That is a bug a developer made,...
Read more >
Re-throwing exception in NodeJS and not losing stack trace
The problem with creating a new Error is you can lose metadata that was attached to the original Error that was thrown, the...
Read more >
Uncaught errors in Node.js and the browser
This article looks into what happens with unhandled errors both in Node.js and in the browser.
Read more >
Node.js Error Handling Best Practices - Sematext
It has an error.stack field that gives you a stack trace showing where the error came from. It also lists all functions that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found