Skip to content
Bishal Rajbahak

लेख · 04 MIN

Lessons from Debugging a Stubborn Bug

A bug with no error message that only failed some of the time. How I tracked it down step by step, and the five-step debugging process I use now.

Some bugs are easy to fix. Others stay hidden long enough to test your patience, your assumptions, and your debugging process. This is the story of one of those bugs and what it taught me.

The bug

At first the problem looked small. Part of the application was not behaving the way I expected, but no error message said what was wrong. Other parts of the app still worked, which made it even more confusing.

That is what made it stubborn. It did not break everything at once. It only failed in certain situations, so it was hard to trace.

What I tried first

My first instinct was to fix the most obvious suspect. I checked the component, the API response, and the data flow, hoping the problem was there. Each fix either solved part of the issue or changed nothing at all.

That was the first lesson: the first thing that looks wrong is often not the real cause.

Finding the real cause

So I slowed down and went through the problem step by step. I checked the inputs, the outputs, the state changes, and how data moved through the application. I also paid closer attention to the logs and to small differences between what I expected and what actually happened.

The bug was not where I first thought. It came from a small detail in the flow that I had overlooked. Once I understood the real source, the fix itself was simple.

What I learned

Debugging is a skill. When something is broken it is easy to jump to conclusions, but real progress comes from slowing down and understanding the system.

Stubborn bugs also expose weak spots in how I think about my code. They show me where I made assumptions, where I skipped steps, and where I need better structure or better logging. I hit the same pattern while building a login flow, which I wrote about in What Building Authentication in Go Taught Me About Security.

How I approach bugs now

When I face a difficult bug now, I follow the same steps:

  1. Reproduce the issue reliably.
  2. Isolate the smallest part that fails.
  3. Check the logs and state changes carefully.
  4. Hold off on guessing until the evidence points somewhere.
  5. Fix the root cause, not the symptom.

That process saves time and frustration, and it usually leads to a better fix.

Frequently asked questions

What is the first step in debugging a hard bug?

Reproduce it reliably. If you can't make the bug happen on demand, you can't tell whether a fix worked. Find the exact steps, data or conditions that trigger it before you change any code.

How do you debug a bug that has no error message?

Compare what you expect with what actually happens at each step. Log the inputs, outputs and state changes along the flow, and find the first point where they differ from what you expected. That point is usually close to the real cause.

Why do intermittent bugs take so long to fix?

Because they only fail under certain conditions, so the obvious suspects often look fine when you check them. The fix is usually simple once found; the time goes into narrowing down which conditions trigger the failure.

How do I stop guessing when debugging?

Write down what the evidence actually shows before you change anything, and only change one thing at a time. If a fix "partly works", treat that as a clue that you haven't found the root cause yet.

What's the difference between fixing a symptom and fixing the root cause?

A symptom fix makes the visible problem go away, for example by adding a check where the bad value shows up. A root-cause fix stops the bad value from being created in the first place, so the same bug can't reappear somewhere else.

Closing thoughts

This bug was annoying while I was solving it, and it became one of the most useful things I learned from. Good developers still get stuck. What sets them apart is that they keep going until they understand the problem.

Every stubborn bug teaches something. This one taught me patience, structure, and the value of careful debugging.

  • Debugging
  • Problem solving
  • Web development

All writing

EditionKathmandu