get-shit-done/references/common-bug-patterns.md
Checklist of frequent bug patterns to scan before forming hypotheses. Ordered by frequency. Check these FIRST — they cover ~80% of bugs across all technology stacks.
<patterns>null or undefined, missing null check or optional chainingundefined instead of expected value, missing return statement or wrong branchnull/undefined, API returned error shape instead of datalength instead of length - 1< vs <=, slice/substring end index.length === 0 falls through to logic assuming items existawait, gets Promise object instead of resolved valueundefinedimport X vs import { X }.js vs .cjs vs .mjs, .ts vs .tsx"5" > "10" is true (lexicographic), 5 > 10 is false== instead of ===, truthy/falsy surprises (0, "", [])0.1 + 0.2 !== 0.3, large integers lose precision0 or "" which is valid but falsydata vs data.results vs data[0]g flag with .test() then .exec(), lastIndex not reset between calls. matches any char, $ is special, backslash needs doubling.* eats through delimiters, need .*?catch {} or logs but doesn't rethrow/handleError when specific type needed.catch() or try/catch around awaitvar i, use let or bind.bind() or arrow functionvar hoisted to function, let/const block-scoped| Symptom | Check First |
|---|---|
| "Cannot read property of undefined/null" | Null/Undefined Access |
| "X is not a function" | Import/Module, Type/Coercion |
| Works sometimes, fails sometimes | Async/Timing, State Management |
| Works locally, fails in CI/prod | Environment/Config |
| Wrong data displayed | Data Shape, State Management |
| Off by one item / missing last item | Off-by-One/Boundary |
| "Unexpected token" / parse error | Data Shape, Type/Coercion |
| Memory leak / growing resource usage | Async/Timing (cleanup), Scope/Closure |
| Infinite loop / max call stack | State Management, Async/Timing |