I'd been at the same bug for the better part of two days. It was a race condition, which is to say it was the worst kind, the sort that vanishes the moment you add a log line and reappears the instant you take it away. I'd read the same forty lines of code so many times that the words had stopped meaning anything, the way a word does when you say it too many times out loud.
So I stopped. Put the laptop to sleep, wheeled the bike out, and went up the lane towards the hills with no particular destination. The trick, if it's a trick at all, is that you can't force this. If you go out telling yourself you'll think about the bug, you just bring the same stuck loop with you on two wheels instead of at a desk. You have to actually let it go and pay attention to the hill.
About forty minutes in, grinding up a climb I'd stopped enjoying somewhere near the bottom, it arrived. Not the fix exactly, but the thing I'd missed: I'd been assuming two callbacks couldn't run at the same time, and there was nothing whatsoever guaranteeing that. The shared state I'd been so carefully reasoning about had no lock around it because, in my head, it didn't need one. The bike didn't solve it. The bike just got my head out of the rut long enough for the obvious thing to be obvious.
I didn't even rush home. I finished the ride, because turning round at that point would have been admitting the bike was just a tool for debugging, and it isn't, it's the thing that lets the debugging happen. The fix took four lines when I got back: a mutex and a tightened critical section. Two days at the desk, forty minutes on a hill.
There's a tidy productivity-blog version of this where the lesson is "take breaks to be more efficient", and I don't much like it, because it makes the ride instrumental, a means to an end. The honest version is that staring harder at code that isn't working is one of the least useful things an engineer can do, and the human brain seems to do its best joining-of-dots when you stop demanding it. The hill was good. The fix was a bonus.