0

I have a NodeJS application that gets bundled via webpack before being deployed. In production, what's run is a single bundled dist/server.js file.

I'm having trouble debugging some errors in production, errors that don't always appear when I run it locally (even running dist/server.js locally). The issue isn't the errors that I'm encountering, but rather that the error log to stdout gets cut off due to server.js being so large. It's trying to write the stack trace, but it's writing this enormous file which is too large for the stdout buffer.

If I could see what these errors are, I'm sure I could fix them quickly. How can I tell node to not write the stack trace? Or, if there's some other way to log the error first, that would work, too.

Kyle Baran
  • 37
  • 5
  • ideally, it shouldn't be outputting anything on production, you shouldn't use console.log (it slows down your app) and should catch and handle all thrown errors.. but.. you can instead write them errors to file and then use `cat`, `tail` or `head` to read the logged file.. see https://stackoverflow.com/questions/32719923/redirecting-stdout-to-file-nodejs – Lawrence Cherone Nov 20 '20 at 00:43
  • This is a useful direction, though unfortunately the exact environment I'm using makes it difficult to access a log file. I'm trying to debug some Agones-managed Kubernetes pods. As soon as this failure occurs, Agones terminates the pod and spins up a new one to replace it. There's a roughly 5-second window that the pod is not either spinning up or terminating, and it's rather difficult to access the pod in such a short timeframe. – Kyle Baran Nov 20 '20 at 08:05

0 Answers0