Above my screen, I have simple reminder: “IT IS ALWAYS TIMEZONES.” It used to be a simple black-and-white sign until my daughter decided it needed to be turned into a brilliant rainbow of a warning.
The sign was put up after experiencing not one but two timezone-related bugs within a relatively close proximity. Periodically, I’ll see something similar crop up like a test failing before 10am, but not after, thanks to the differences between what day of the week it is in UTC vs my local computer (in +1000 or +1100, depending on the day).
In a work discussion yesterday we talked about debugging checklists and I wrote up one with what I could think of. I’m sharing it here as it might be useful to others. Maybe there’ll be more signs that come out of it.
First: have you eaten or drunk anything recently? Do you need to take a break?
Then:
- Are you in the right app?
- Right file?
- Right function?
- Is the function spelled correctly?
- If you’re running locally:
- Is the server up?
- Is the server running on the port you expect?
- Is there information in the logs?
- Can you add more logs to provide more useful information? (Usually, yes.)
- Can you reduce other logging to focus on just what you need?
- Are you sure you’re in the right environment (local / staging, etc) for this?
- Can you inspect this function to determine if it is what you expect?
- Is the input what you expect?
- Is the output what you expect?
- Are there intermediary steps where the input is transformed into a new form?
- Is it a string issue?
- Does casing matter in this situation?
- Are you comparing this string to another? Inspect both to see any differences.
- Does pluralization or non-pluralization of the string matter?
- Are there extra characters blank spaces?
- Null-byte prefix? (check with #codepoints)
- If the behaviour is new:
- Do you see this behaviour on the main branch, or just your own?
- If you see it on the main branch, can you use
git bisect
to find out when this issue was introduced? - Were there packages updated recently that may have introduced this bug?
- Is an exception happening, and then being rescued too quickly by something like
rescue
orrescue StandardError
?- Can you narrow down the exception class to something more specific?
- If it is a time bug:
- Is it a different day in UTC compared to your local time?
- Do you need to freeze time for this test?
- Are you certain the time zone your code is running in is the right time zone?
- If it’s an integer / float bug:
- Are there numbers being rounded?
- Can you push the rounding “down” the stack, so it is one of the final operations to simplify?
- If it’s a browser issue:
- Can you reproduce this issue in a different browser?
- Are you trying to use a browser API that is not currently supported in this browser?
- Are there any errors displayed in the console?
- Were there any network requests that failed, or contain errors?
- If this code depends on environment variables:
- Is the environment variable spelled correctly?
- Is the value of that variable what you expect?
- If this code depends on a configuration file:
- Is the configuration file in the right place?
- Is the configuration key set up where you expect it?
- Does that key have the right value?