How to debug software
or, “How I Spent Sunday Afternoon”
- Discover weird bug in new code: every time a mouseenter event occurs on a particular element, a mouseleave event immediately fires on the same element, leading to an endless loop of enter and leave events flickering past.
- Spend some time futzing around with logging and breakpoints, finally resorting to selectively disabling each of the most recent code changes, trying to narrow down what’s causing the extra event.
- Roll back all the way to last Friday’s version of the code, which you could swear was working fine — but the bug’s still there.
- Completely remove the new component from the testbed, leaving only the well-tested framework code that hasn’t been touched in at least a couple of weeks.
- Bug’s still there. Start to panic, just a tiny bit: you’re supposed to demo this code to the client on Wednesday (which is why you’re working over the weekend in the first place.)
- Check in other browsers — no bug. Check on the windows machine — no bug there, even in Firefox. So, okay, we’ve narrowed it down to the OSX version of Firefox.
- Start doing global searches across the entire codebase for anything that could be setting a mouseenter or mouseleave event. In exasperation, disable all of them.
- Bug’s still there.
- Get up from computer, pour a cup of coffee, put away dozens of scattered toddler toys, vacuum entire house, do physical therapy exercises rather more emphatically than usual. Find cup of tepid coffee still sitting on the counter where you forgot it after pouring.
- Sit back down at computer. Oddly enough, the bug is still there.
- Revert code to latest version, as it was back in step 1.
- Quit Firefox. Restart Firefox. Reload page.
- Bug is gone.
THE CALL WAS COMING FROM INSIDE THE DEBUGGER ALL ALONG