Debugging in Production: The Power of a Debugger

PM: "Hey bro, our app is breaking in production!" 🚨 Me: Proceeds to check logs on production.. Sees error but couldn't reproduce. Reason? Because the actual issue would lead to an unhandled exception without logging the error, and subsequent retry would throw another error. There's no way we could reproduce or debug the real error using console.log or print logging. Despite having around 800+ console.log and console.errors overall, multiple attempts to reproduce this one tiny issue were unsuccessful. That's when I switched to the debugger.  - Watched code execution line by line - Stepped into the loop execution - Paused my code exactly right before it would crash Turns out a small whitespace in the filename was rejected by the file upload API, causing the error. And as soon as this error was raised, Lesson: console logging might be good for simple, quick debugging, but in production-grade applications with 1000+ lines of code, a debugger comes to the rescue. Also, those 100s of console.log statements during development are a pain to remove and would cause runtime costs in production. The benefits of a debugger far outperform the ease of console.log.  - see my code running line by line,  - trace back the call stack,  - see runtime variables,  - see closures in action,  - pause it at the desired state of the program and play with the values.  That's another level of satisfaction too, tbh. I always prefer adding a production logger (will talk about this in another post)  and prefer a debugger instead of print debugging. Take your debugging to the next level and try using a debugger in your next project! 💻 #debugging #programming #softwaredevelopment #coding #developerlife #codingtips #debugger #logging

  • No alternative text description for this image

But, you can't use a debugger in production. Most of the issues you pointed can be fixed by using a logger (filtering logs by level or querying them)

Like
Reply

I absolutely agree with you there, without proper guidance many people will waste 100s of hours doing something that could take 30 minutes. The setbacks from moments like these are detrimental to a team and a budget.

See more comments

To view or add a comment, sign in

Explore content categories