Increasing stack trace size
A stack trace, sometimes referred to as a stack backtrace, is defined as a list of stack frames. When your Node.js process hits an error, a stack trace is shown detailing the function that experienced the error, and the functions that it was called by. By default, Node.js’s V8 engine will return 10 stack frames.
When debugging some errors, it can be useful to have more than 10 stack frames. However, increasing the number of stack frames stored can come with a performance cost. Keeping track of additional stack frames will result in our applications consuming more memory. For more details, you can refer to this link: https://v8.dev/docs/stack-trace-api.
In the recipe, we’re going to increase the size of the stack trace.
Getting ready
- First, we should create a directory for our application. We’ll be using the
express
module for our program, so we’ll also need to initialize our project directory:$ mkdir stack-trace...