| name | debugging-error-tracking |
| description | Systematic debugging workflow for errors, performance issues, and runtime problems in the portfolio. |
Debugging & Error Tracking
When to use this skill
- Investigating console errors or warnings
- Debugging hydration mismatches
- Tracking down performance regressions
- Diagnosing network request failures
- Analyzing memory leaks or slow render cycles
- Troubleshooting browser-specific issues
Workflow
1. Error triage
Classify the error:
| Category | Examples | Priority |
|---|
| Build-time | TypeScript errors, lint failures, missing imports | Fix before commit |
| Runtime | Console errors, unhandled promises, null references | Fix before deploy |
| Hydration | Server/client HTML mismatch, useEffect missing | Fix before deploy |
| Network | API failures, CORS errors, timeout | Fix based on user impact |
| Performance | Slow LCP, high CLS, janky animations | Fix if regression |
| Browser-specific | Safari-only, mobile-only, Firefox-only | Fix if significant audience |
2. Console error investigation
Step 1: Reproduce the error
- Open browser DevTools → Console tab
- Clear console and reload the page
- Note the exact error message, file, and line number
Step 2: Read the error carefully
- The first line is the error type (TypeError, ReferenceError, etc.)
- The second line is usually the component stack trace
- Look for the file path and line number in the source
Step 3: Check common patterns
| Error pattern | Likely cause | Fix |
|---|
Cannot read property of undefined | Null data from API | Add null checks or ?? defaults |
Hydration mismatch | Server/client render difference | Add useEffect guard, mounted state |
Too many re-renders | State update in render | Move to useEffect or callback |
Invalid hook call | Conditional hook or wrong React | Ensure hooks are called unconditionally |
404 on _next/static | Stale service worker | Clear SW cache (see PWA skill) |
CORS error | Missing headers | Check API route CORS config |
3. Hydration mismatch debugging
Symptoms: Warning in console about hydration mismatch, content flickers on load.
Common causes:
-
Date/time rendering -- Server and client generate different strings
<span>{new Date().toLocaleDateString()}</span>
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
<span>{mounted ? new Date().toLocaleDateString() : ''}</span>
-
Browser extensions -- Extensions inject elements into the DOM
- Test in incognito mode with extensions disabled
-
Conditional rendering based on window/document
<div>{typeof window !== 'undefined' ? 'client' : 'server'}</div>
const [isClient, setIsClient] = useState(false);
useEffect(() => setIsClient(true), []);
4. Network request debugging
DevTools → Network tab:
- Filter by
Fetch/XHR to see API calls
- Check the
Status column for failures (4xx, 5xx)
- Click the failed request →
Preview tab for error details
- Check
Response Headers for CORS issues
Common network issues:
| Status | Meaning | Fix |
|---|
| 400 | Bad request | Check request body/params |
| 401 | Unauthorized | Check API token |
| 403 | Forbidden | Check permissions/CORS |
| 404 | Not found | Check the API route exists |
| 429 | Rate limited | Add retry logic, back off |
| 500 | Server error | Check server logs |
| CORS error | Missing Access-Control-Allow-Origin | Add CORS headers to API route |
5. Performance debugging
Chrome DevTools → Performance tab:
- Click record, interact with the page, stop recording
- Look for long tasks (red bars in the timeline)
- Check the
Summary tab for breakdown (scripting, rendering, painting)
React DevTools → Profiler:
- Open React DevTools → Profiler tab
- Click record, interact, stop
- Check which components re-rendered and why
- Look for components rendering too often (unnecessary re-renders)
Quick performance checks:
npx lighthouse http://localhost:3000 --output html --view
npm run build 2>&1 | grep -E "First Load|shared"
6. Memory leak detection
DevTools → Memory tab:
- Take a heap snapshot
- Perform actions (navigate, open modals, etc.)
- Take another snapshot
- Compare snapshots -- look for detached DOM nodes
Common memory leak sources:
- Event listeners not cleaned up in
useEffect return
setInterval not cleared
- SWR fetchers holding references
- Third-party widgets (analytics, chat) not disposed
7. Mobile debugging
Chrome DevTools → Toggle Device Toolbar:
- Select a device preset (iPhone, Pixel, etc.)
- Check for touch event issues
- Verify tap targets are ≥ 44px
- Test scroll behavior (iOS momentum scrolling)
- Check for viewport meta tag issues
Remote debugging (real device):
- Android:
chrome://inspect with USB debugging
- iOS: Safari → Develop → [device]
Quick reference
| Problem | First thing to check |
|---|
| Page is blank | Console errors, build errors |
| Data not loading | Network tab, API routes |
| Styling broken | Tailwind classes, dark mode toggle |
| Slow page | Performance tab, bundle size |
| Works on desktop, broken on mobile | Responsive breakpoints, touch events |
| Works in Chrome, broken in Safari | CSS features, JS compatibility |
| Intermittent error | Race conditions, async timing |
Delivery checks