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. The number of stack frames stored comes with a performance cost. Keeping track of additional stack frames will result in our applications consuming more memory and CPU.
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-app $ cd stack-trace-app $ npm init --yes $ npm install express
- We'll need a few files for this...