Debugging method
Change one variable
Design a controlled experiment, predict both outcomes, and preserve the result before the next change.
10 minute lesson
If you change code, configuration, dependencies, and data together, success reveals almost nothing about which change mattered. The bug is gone, but you cannot say what was wrong, whether the other changes are safe, or whether the fix survives the next deploy.
Debugging experiments work like controlled experiments anywhere: one variable per run.
Write the experiment before you run it
Write the experiment first:
hypothesis: API base URL points at the old port
change: override only API_BASE_URL to port 4000
prediction if true: request connects and reaches authentication
prediction if false: connection failure remains
The two predictions are the important part. If you cannot say what “true” and “false” look like before the run, the experiment cannot teach you anything. You will read any outcome as vaguely supporting whatever you already believed.
Run it once in the same starting state. Same data, same browser profile, same commit. If your reproduction card says the bug fires 5 of 5 times, one clean run is enough to read the result.
Restore between experiments
Restore the variable before testing another hypothesis. This is the step everyone skips. After three unrestored experiments you are debugging a system nobody has ever seen: old port plus new flag plus edited config. When something changes now, you cannot attribute it to anything.
A practical pattern in a git repository:
git stash # park the current experiment
git stash pop # bring it back when you need it
One stash per hypothesis keeps each change isolated and reversible. Config overrides work the same way: set them on the command line for one run instead of editing files, and they clean themselves up.
When runs are expensive
In production you rarely get free experiments. Keep emergency production changes small, authorized, logged, and reversible — and still write the prediction first. A rollback with a written prediction (“error rate returns to baseline within five minutes”) is an experiment too. If the prediction fails, the deploy was not the cause, and you just saved yourself from ending the investigation too early.
Lesson completed