er-raj-aryan.medium.com 3 min read Original Source

🐞 The Debugging Journey: Frontend Techniques That Saved My Sanity

A few months ago, I found myself stuck in a late-night debugging spiral. One of our key features had suddenly stopped working in production. The UI was broken, users were complaining, and my console looked like a Christmas tree of red errors.

But instead of panicking, I took a breath and followed a series of techniques that I now treat like a debugging ritual. Today, I’m sharing these techniques — not as a list of tips, but as a story of how they helped me save time, reduce stress, and actually enjoy debugging.

Act 1: The Symptom

It started with a weird UI bug. A dynamic dropdown wasn’t populating options for some users. It worked perfectly on my machine, but not on staging. And definitely not on production.

My first instinct? “It’s probably just a minor glitch.” Classic. But that’s the mindset that burns hours.

Act 2: The Console Whisperer

My first real step was opening the DevTools console. It screamed:
TypeError: Cannot read properties of undefined (reading 'map')

Alright. That meant somewhere, something was expected — but missing. I used breakpoints in Chrome DevTools (right-click → “Add breakpoint”) and stepped through the function line by line.

🔧 Technique #1: Breakpoints over Console.log

While console.log() is easy, breakpoints are more powerful. They let you:

  • Pause execution at exactly the right line.
  • Inspect all variables, DOM state, and call stack.
  • Watch variables in real-time as the app executes.

Within minutes, I discovered the dropdown was expecting props.options, but sometimes props was undefined entirely. Boom—first clue.

Act 3: The Network Detective

Next stop: Network tab. I reloaded the app and saw a 401 error on the API that was supposed to fetch options. My auth token had expired.

🔧 Technique #2: Use Network Tab Like a Detective

With the Network tab:

  • Reproduce the bug and watch API calls.
  • Check status codes, response payloads, and headers.
  • Confirm if data is missing, malformed, or unauthorized.

I realized the issue was a race condition where the token hadn’t been refreshed before the API call fired.

Act 4: Local Storage, Session Storage, and Cookies

While the token issue was part of the bug, I needed to confirm if the right token was even being saved. Cue the Application tab in DevTools.

🔧 Technique #3: Inspect Browser Storage

This helped me:

  • Check if localStorage and sessionStorage had the correct tokens.
  • Manually remove or change keys to simulate different states.
  • Verify that the token logic in useEffect() wasn’t firing as expected.

One line of async code was out of order. Fixing that made the dropdown work again.

Act 5: React DevTools to the Rescue

The UI still felt clunky. Even though data was loading, the dropdown wasn’t rerendering immediately. Enter: React DevTools.

🔧 Technique #4: Use React/Vue DevTools

With React DevTools:

  • I checked component props and state in real-time.
  • Verified which components re-rendered and when.
  • Spotted unnecessary re-renders and fixed them with React.memo.

I found out the dropdown component was wrapped in a memo() but wasn’t receiving updated props because of incorrect key usage.

Act 6: Mobile Debugging and Cross-Browser Checks

My team later reported the issue still persisted for some Android users. That’s when I opened remote debugging tools:

  • Used Chrome’s remote device emulator.
  • Checked the layout on different screen sizes.
  • Used BrowserStack to test on real Android devices.

Sure enough, an older browser was missing a polyfill.

🔧 Technique #5: Emulators and Cross-Browser Tools

Testing across environments early helps catch edge-case bugs before they reach production. Add these to your toolbox:

  • Chrome mobile emulation
  • Safari’s Web Inspector (for iOS debugging)
  • BrowserStack or LambdaTest

Final Scene: A Debugging Toolkit That Actually Works

By the end, I had fixed not just one bug, but uncovered three separate issues:

  • Race condition on API calls
  • Incorrect component memoization
  • Lack of cross-browser support

And I didn’t have to rip my hair out.