Book Image

Node Cookbook - Fourth Edition

By : Bethany Griggs
4 (1)
Book Image

Node Cookbook - Fourth Edition

4 (1)
By: Bethany Griggs

Overview of this book

A key technology for building web applications and tooling, Node.js brings JavaScript to the server enabling full-stack development in a common language. This fourth edition of the Node Cookbook is updated with the latest Node.js features and the evolution of the Node.js framework ecosystems. This practical guide will help you to get started with creating, debugging, and deploying your Node.js applications and cover solutions to common problems, along with tips to avoid pitfalls. You'll become familiar with the Node.js development model by learning how to handle files and build simple web applications and then explore established and emerging Node.js web frameworks such as Express.js and Fastify. As you advance, you'll discover techniques for detecting problems in your applications, handling security concerns, and deploying your applications to the cloud. This recipe-based guide will help you to easily navigate through various core topics of server-side web application development with Node.js. By the end of this Node book, you'll be well-versed with core Node.js concepts and have gained the knowledge to start building performant and scalable Node.js applications.
Table of Contents (14 chapters)

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

  1. 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
  2. We'll need a few files for this...