Ramblings of an aging IT geek
← Ramblings of an aging IT geek
personal

the bug that needed an hour on the bike

A note on why the answer to a stuck bug usually arrives somewhere around mile eight, away from the keyboard entirely.

A cup of coffee beside books

I had been staring at the same stack trace for most of the morning. You know the kind. Not a hard bug, not really, just a sticky one, the sort where you've read the same forty lines so many times that your eyes slide off them and your brain has quietly stopped reading and started reciting. I'd added log lines. I'd added more log lines. I'd reached the stage of adding log lines to the log lines. So I closed the laptop and went out on the bike.

February in the lanes is not glamorous. It was grey, it was about four degrees, and the first ten minutes were the usual argument with myself about whether this was procrastination dressed up as strategy. It was a bit of both, if I'm honest. But there is a thing that happens once the legs are turning and the road is just cold and quiet, where the part of your head that was clamped onto the problem finally lets go of it, and the answer wanders in through a side door.

A grey winter landscape

It was somewhere on the long drag out past the reservoir that it arrived, fully formed and faintly embarrassing. The state I was sure got reset on each request was being shared across requests, because the thing holding it was constructed once at startup and not per-call. I hadn't seen it because I'd been reading the handler in isolation, and the bug lived in the wiring two files away, in a line I'd written months ago and stopped seeing.

I didn't turn round and sprint home. That's not how it works for me, and the bug wasn't going anywhere. I finished the loop, got cold and a bit wet on the descent, had the good kind of tired by the time I racked the bike. Then I fixed it in about four minutes, which is roughly the ratio I've come to expect: hours of staring, an hour of pedalling, four minutes of actual typing.

I used to feel slightly guilty about this, as though stepping away from the screen was admitting I wasn't trying hard enough. I've made my peace with it. The staring isn't wasted; it loads the problem into your head, which is the bit the bike can't do. But the loaded problem needs somewhere quiet to settle, and the screen is the least quiet place I know. The bike, the kettle, the walk to the shop, the shower: these are not breaks from the work. They are where a particular kind of the work happens, the kind you can't force.

So this is less a tip than a permission slip. If you're an hour into reading the same trace and getting nowhere, the most productive thing you can do might be to put on a coat and leave the building. The bug will keep. The lanes are cold but they're good for thinking, and you can't add a log line at fifteen miles an hour, which turns out to be exactly the point.