Sometimes, one word is all it takes to make your code work

27 June 2024

I just spent two days debugging a feature in an application I’m building. For the life of me, I couldn’t figure out what was going on. After rewriting the code a couple of times and still getting nowhere, I took a break until the next day (today) and came back to it with fresh eyes.

It was actually pretty simple in the end and obvious when I stepped back. I was missing one little word in the code… and that word was await. That’s all it was! The rest of the code carried on running before the method in question had finished running. Really obvious, and totally not at the same time. Two days of debugging and rewriting!

So the lesson to myself here, is always make sure to await. And take breaks.