Files
2nd/10_Wiki/Topics/Domain_Programming/Frontend/Debugging Frontend Applications.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +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 |