Guides

How to reproduce an intermittent bug.

An intermittent bug happens sometimes and not others. To pin one down, write down what you saw while you still remember it, measure how often it happens, then change one thing at a time until it happens on demand. If it never will, report it anyway, with evidence from the moment it appeared.

1. Write it down straight away

Memory of the last few steps fades within minutes. Before you try anything else, note the time, what you were doing in the seconds before, what was on screen, and anything unusual: a slow start, another app busy, a network change. A bug that "just happened" is easier to chase when you have its exact moment.

2. Measure how often it happens

Mozilla's bug writing guidelines ask reporters to say whether a bug happens "at will, occasionally, or not at all", and note that intermittent bugs need extra detail to be useful. Repeat the steps ten or twenty times and count. "3 of 20" is a result a developer can work with. "Sometimes" is not. If you can automate the steps, loop them: Mozilla's test tools have --repeat and --run-until-failure options for exactly this.

3. Change one thing at a time

Intermittent bugs usually depend on something you are not looking at. Vary one factor per round, and keep the rest the same:

  • Data. A different account, a larger or empty record, special characters in a name.
  • State. A fresh start against a long-running session, or the first run after a restart.
  • Timing. Acting faster or slower than normal, or clicking before a page has finished loading.
  • Environment. Another browser, another operating system version, a virtual machine.

4. Slow the machine down or load it up

Many intermittent bugs are timing problems: two things that usually finish in one order sometimes finish in the other. Mozilla's guide on debugging intermittent test failures says they are "often caused by race conditions" and suggests changing timings on purpose. Its advice includes slowing the CPU, running in a virtual machine so repeated runs do not lock up your own computer, and loading the machine with a stress tool. It says stress-ng "has proven to be very effective in reproducing intermittent failures". Slowing the network works the same way for bugs that depend on a response arriving late.

5. Add logging and try again

If you cannot make it happen locally, add logging around the suspect step and run it again. Mozilla's guide suggests exactly that: more logging, then another run. Log the state before and after the step, with timestamps, so the next occurrence tells you more than this one did.

6. If it will not repeat, capture it when it does

Some bugs never reproduce on demand, and a report that says so is still useful if it comes with evidence from the moment: a screen recording, the time, the version, and the exact state. The problem is that you only know the bug has happened after it has. Recording everything all day is heavy, and starting to record is too late. A rolling buffer keeps just the last few minutes, so you can save the moment after you see it. Recording a bug after it already happened explains how.

Doing this with Bugback

Bugback keeps the last few minutes of your screen in memory. When the bug appears, press ⇧⌘H and the moment is saved, including the seconds before it. The free plan keeps 10 or 30 seconds, and Pro keeps 1 to 10 minutes. Trim the clip, add what you noticed, and attach it to the ticket with the count from step 2 and what you changed in step 3. See how to write a good bug report for what else goes in.

Download Bugback for macOS, or see pricing.