An obvious bug
Debugging is one of the things I enjoy about programming. It’s like a little puzzle to solve. But as code gets more complicated, the little bugs can hide themselves in ways that make them very, very, annoyingly hard to find. This one, minimally reproduced in this Codepen, got me this week:
It seems obvious — an empty input calculates an invalid date. But then imagine the calculated date was never visible, an empty input is considered valid data, and the system that reported this being an issue was 3 microservice hops away.
And the real issue, it turns out, was ever using
parseInt. Day.js can do the calculation just fine with strings.
Posted: April 2022