Reading a Stack Trace (The Skill Nobody Teaches)
The Wall of Red Text Isn't Random
The first time a real error crashes your program, it's tempting to skim past the giant block of text and just Google the first line. That works sometimes. It also means you never build the actual skill - reading a stack trace top to bottom and knowing exactly where to look - which is one of the fastest ways to look like you know what you're doing in a code review or an incident channel.
TypeError: Cannot read properties of undefined (reading 'email')
at getUserEmail (/app/src/users.js:42:19)
at processOrder (/app/src/orders.js:18:23)
at /app/src/server.js:55:5
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)Read from the top. The first line is the actual error and error type - here, something was undefined and code tried to read `.email` off it. The lines below are the call stack: the exact chain of function calls that led to the crash, most recent call first. `getUserEmail` at `users.js:42` is where it actually broke; `processOrder` is what called it; `server.js` is what called that.
You almost never need to read the whole trace. Find the first line that points into YOUR code (not node_modules or a framework's internals) - that's usually where the actual bug lives, even if the crash technically happened a few frames deeper inside a library function you called.
In this example: `getUserEmail` assumed it always receives a user object with an email field, but something upstream passed it `undefined` - probably a user lookup that failed silently. The fix isn't in the line that crashed, it's in figuring out why an undefined value got that far in the first place.