The universal developer experience. No codebase is immune. Here's the week's collection of bug-related developer pain dressed in humor.
// Bug report: Button sometimes doesn't submit form
// Root cause: Found it!
// Before (broken):
button.addEventListener('click', submitForm);
// After (fixed):
button.addEventListener('click', (e) => {
e.preventDefault();
submitForm();
});"Done! Simple fix. Should be fine."
QA: "The fix works, but now the form doesn't submit at all on mobile."
// Ah. The form was relying on the default behavior we just prevented.
// And mobile handles touch events differently.
// And submitForm() has a bug we never noticed because the form
// was never actually being submitted correctly before."How long has this bug existed?"
checks git blame
git blame submit-form.js
abc1234 (firstdev@company.com 2021-03-14): initial commit
The form has been broken for 3 years. Nobody noticed because the broken behavior happened to work in most cases.
Originally: Fix button click bug
Now also:
- Refactor the entire form submission logic
- Add mobile touch event handling
- Fix the underlying submitForm bug
- Add proper error handling that was missing
- Write tests (there were none)
- Update the component to use React Hook Form
Estimated time: 30 minutes → Actual time: 3 days
User: "It crashes every time I click the save button"
Dev: "I can't reproduce it. Let me watch you do it."
*User shares screen*
User: "See, I click save and— oh. It works."
Dev: "..."
User: "It was doing it all day!"
Dev: "I'll put in some logging"
*Bug never appears again for 2 weeks*
*Bug appears in production at 2am*
*Dev is on vacation*
Monday: User reports bug
Developer: "I'll look at it" (doesn't look at it)
Tuesday: Another user reports same bug
Developer: "Adding to backlog"
Wednesday: Third user reports it
Developer: "Marking as priority"
Thursday: 50 users report it
Developer: "What? Why didn't anyone tell me?"
Entire team: "..."
git commit -m "fix: hopefully resolve the flaky login issue"
git push
# 2 hours later in Slack:
Team: "Is the login thing fixed?"
Dev: "I think so? Let me know if it happens again."
Team: "It happened again."
Dev: "..."Every bug you fix correctly is one fewer bug. Every bug you patch incorrectly is three more bugs in a trench coat.
Fix the root cause. Always.