Files
2nd/10_Wiki/Topic_Programming/Frontend/Debugging Frontend Applications.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

166 lines
5.0 KiB
Markdown

---
id: wiki-2026-0508-debugging-frontend-applications
title: Debugging Frontend Applications
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Frontend Debugging, DevTools Workflow]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [debugging, devtools, performance, chrome]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: JavaScript/TypeScript
framework: Browser DevTools
---
# Debugging Frontend Applications
## 매 한 줄
> **"매 frontend 디버깅 = DevTools 의 mastery + reproducible state."**. Chrome DevTools (2024-2026)는 매 Performance Insights, AI assistance (Gemini Nano), Recorder, Memory profiler 의 통합. 매 핵심은 매 issue 의 reproduction → instrument → bisect → fix.
## 매 핵심
### 매 DevTools panels
- **Sources**: breakpoint, conditional bp, log point, blackbox.
- **Performance**: flame chart, INP / LCP markers, Performance Insights.
- **Network**: throttle, replay XHR, request blocking.
- **Memory**: heap snapshot, allocation timeline.
- **Application**: storage, service worker, cache.
- **Lighthouse / Recorder**: automated audit + user flow capture.
### 매 reproduction
- 매 hard bug = race / state / network / timing.
- 매 deterministic repro = first 50% of debug.
### 매 응용
1. Memory leak hunt — heap snapshot diff.
2. Slow render trace — Performance flame.
3. Network race — Replay & throttle.
4. Production-only bug — source-mapped stack + Sentry replay.
## 💻 패턴
### 1. Conditional breakpoint / log point
```javascript
// Sources panel: right-click line number
// Conditional: user.id === 42
// Log point: console.log('user', user) — 매 코드 수정 X
```
### 2. debugger keyword + dynamic
```javascript
function process(items) {
if (items.length > 1000) debugger; // pause when large
// ...
}
```
### 3. console.* advanced
```javascript
console.table(users);
console.group('render');
console.time('paint'); // ...
console.timeEnd('paint');
console.groupEnd();
console.dir(node); // DOM as JS object
console.trace();
console.count('clicked');
```
### 4. Performance.measure (User Timing)
```javascript
performance.mark('fetch-start');
await fetch('/api/x');
performance.mark('fetch-end');
performance.measure('fetch', 'fetch-start', 'fetch-end');
// shows in DevTools Performance + reportable to RUM
```
### 5. Long Task observer
```javascript
new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (entry.duration > 50) console.warn('long task', entry);
}
}).observe({ type: 'longtask', buffered: true });
```
### 6. Heap snapshot leak hunt
```text
1. DevTools → Memory → "Heap snapshot" (baseline).
2. Trigger interaction (open/close modal 5x).
3. Take 2nd snapshot.
4. Compare: filter by "Objects allocated between snapshots".
5. Look for retained DOM nodes / event listeners.
```
### 7. Network throttle & replay
```text
- Network panel → "No throttling" → "Slow 4G" / Custom (300ms RTT).
- Right-click request → "Replay XHR" / "Block request URL".
- Override response: Sources → Overrides → Network → Save.
```
### 8. Source map verification
```bash
# Verify upload
curl -I https://cdn.example.com/main.js.map
# In DevTools, check status: open Sources, file should show formatted code
# If "missing source map", check //# sourceMappingURL comment + CORS
```
### 9. React DevTools Profiler
```text
- Components tab — inspect props, hooks, set Suspense state.
- Profiler tab — record interaction, view "Why did this render?" (commit reason).
- Highlight updates when components render: settings cog → "Highlight updates".
```
### 10. Chrome AI assistance (2024-)
```text
- DevTools Console → "Ask AI" (Gemini Nano integration).
- "Why is this CSS not applying?" — pastes computed styles into prompt.
- Performance Insights — auto-flagged INP / CLS culprits.
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Slow render | Performance panel + React Profiler. |
| Memory leak | Heap snapshot diff. |
| Race condition | Network throttle + console.trace. |
| Prod-only | Source map + Sentry Replay. |
| CSS quirk | DevTools Computed + AI assistance. |
| Long task | PerformanceObserver longtask. |
**기본값**: Repro locally → Performance flame → narrow → fix → regression test.
## 🔗 Graph
- 부모: [[Web Performance]]
- Adjacent: [[Source Maps]] · [[Lighthouse]]
## 🤖 LLM 활용
**언제**: 매 stack trace 의 explain, 매 console.error 의 plausible cause 의 list.
**언제 X**: 매 timing-dependent / state-dependent bug — 매 actual repro 필수.
## ❌ 안티패턴
- **`console.log` ship to prod**: 매 left-over noise.
- **alert() debugging**: 매 modal blocks event loop.
- **Disable source maps**: 매 prod debug 의 X.
- **Profile in prod build only**: 매 dev mode warnings 의 miss.
## 🧪 검증 / 중복
- Verified (Chrome DevTools docs 2024-2026, web.dev).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — DevTools 2026 + AI assistance + Profiler |