İçeriğe geç
Kodlama ve Yazılım Orta

AI ile Debugging: Hata Ayıklama Süreleri 5'te 1'e

ChatGPT, Cursor, Copilot ile debugging: stack trace, error analysis, root cause, regression.

YZ
Paylaş:
Kod hata ayıklama

Debug = developer’ın %50+ zamanı. AI ile bu 5’te 1’e iner. Anahtar: doğru bilgi ver, doğru soru sor.

Stack Trace Analizi

"Bu hata mesajını analiz et:

[error + stack trace]

Stack:
- React 18
- TypeScript
- Next.js 14

Context:
- Production
- User: 500/min
- New release (1 saat önce)

Çıktı:
1. Root cause hypothesis (3 olası)
2. Stack trace yorumla
3. Hangi commit suspect
4. Quick fix (geçici)
5. Real fix (proper)
6. Test ekleme
7. Regression önleme
"

Reproducible Bug

"Bug rapor:

Beklenen: Submit success
Olan: 500 error

Repro:
1. Login as [email protected]
2. Go to /checkout
3. Click "Pay"
4. Error appears

Console:
[paste]

Network tab:
[paste]

Sentry:
[paste]

Çıktı:
1. Repro confirm (yapısal anlat)
2. Hata yeri (server vs client)
3. İlk araştırılacak: nedeni mantıklı 5 yer
4. Debug komut listesi
5. Hipotez sırası (en olası ilk)
"

React Re-render Debug

"Bu component sürekli re-render. Neden?

[Component code]
[Profiler screenshot - description]

Stack:
- React 18
- Hooks

Çıktı:
1. Cause analiz (object referans? state? context?)
2. Why-did-you-render setup
3. React DevTools profiler kullanım
4. Refactor: memo / useCallback / useMemo
5. Anti-pattern: 'always memo everything' tehlike
"

Memory Leak

"Node.js memory leak debug:

Sympton:
- Server memory 2GB → 8GB / 6 saat
- Process crashes
- No clear leak source

Çıktı:
1. Heap snapshot (Chrome DevTools)
2. clinic.js doctor
3. Common Node leak:
   - Closures retain
   - Event listener leak
   - Global var
   - Timer not cleared
   - Stream not consumed
   - Connection not released
4. Reproduce in dev (memwatch)
5. Fix + monitoring
"

Race Condition

"Race condition suspect:

Scenario:
- Two async operations
- Sometimes wrong result
- Hard to reproduce

Çıktı:
1. Race scenarios (5 olası)
2. Add logging (timestamps)
3. Async sequence check
4. Locking strategy (DB row lock, mutex)
5. Optimistic vs pessimistic
6. Idempotency design
7. Test (artificial delay)
"

SQL Query Slow

Detay: Database Tasarım

"Slow query debug:

Query: [paste]
EXPLAIN ANALYZE: [paste]
Time: 5 seconds

Çıktı:
1. EXPLAIN okuma (her node)
2. Bottleneck (seq scan / hash join / sort)
3. Missing index
4. Statistics update (ANALYZE table)
5. Query rewrite alternatif (subquery → CTE → window)
6. Materialized view
7. Hedef: < 200ms
"

Production Crash

"Sentry crash report:

Error: Cannot read property 'name' of undefined
Stack: [paste]
Affected users: 500
First seen: 2 saat önce

Context:
- Release 2.4.0 (deployed 2 saat önce)
- Feature: User profile rewrite

Çıktı:
1. Root cause (kod analizi)
2. Affected user path
3. Impact (revenue, UX)
4. Rollback gerekli mi?
5. Hotfix vs rollback decision
6. Communication (status page + Slack)
7. Post-mortem template
"

Performance Profiling

"Endpoint slow: GET /api/dashboard

Latency: P95 = 3 seconds
Hedef: P95 < 500ms

Stack: Node.js + PostgreSQL + Redis

Çıktı:
1. Tracing (where time spent)
2. DB query count
3. External API call sayısı
4. Cache hit rate
5. JSON parsing cost
6. Network latency
7. Optimizasyon plan (priority)
8. Hedefe ulaşma roadmap
"

Browser Compatibility

"Bug: Safari'de çalışıyor, Chrome'da değil

Feature: Date picker

[code]

Çıktı:
1. CanIUse check (API support)
2. Polyfill needed
3. Vendor prefix
4. Browser-specific bug DB
5. Userland fix (workaround)
6. Test matrix
"

CORS Errors

"CORS error:

'Access to fetch at ... has been blocked by CORS policy:
No 'Access-Control-Allow-Origin' header'

Setup:
- Frontend: app.com
- Backend: api.app.com
- Both production

Çıktı:
1. CORS basics açıklama (preflight vs simple)
2. Backend fix:
   - Access-Control-Allow-Origin
   - Allow-Methods
   - Allow-Headers
   - Allow-Credentials (cookie için)
3. Vary header (cache)
4. Same-site cookie
5. Test verification
"

TypeScript Errors

"TS error:

Type 'X' is not assignable to type 'Y'

[code + error]

Çıktı:
1. Error mesajı yorumla
2. Type mismatch reason
3. Generic constraint
4. Type narrowing (type guard)
5. Discriminated union
6. infer keyword
7. as assertion (anti-pattern!)
8. Refactor önerisi
"

Async / Promise Debugging

"Promise unhandled:

'UnhandledPromiseRejection: Error: ...'

Code: [paste]

Çıktı:
1. Missing catch noktası
2. Error propagation chain
3. async/await vs .then() consistency
4. AbortController (cancellation)
5. Promise.all vs Promise.allSettled
6. Error boundary (React)
7. Global handler
"

Git Bisect Bug Hunt

"Production bug, branch'te yoktu.
Hangi commit getirdi?

10 commit since last green.

git bisect:
- good: v2.3.0
- bad: HEAD
- test command: [...]

AI ile:
1. Bisect script otomatize
2. Her commit'te test
3. Suspect commit identify
4. Revert vs forward fix decision
"

API Integration Bug

"3rd party API integration sorun:

Provider: [Stripe / Iyzico]
Issue: Webhook signature mismatch
Frequency: %5

Çıktı:
1. Signature algorithm anlama
2. Common cause: timing, encoding, body parsing
3. Logging ekleme (raw body, computed sig, expected)
4. Test (curl with known good)
5. Replay capability
6. Fallback (manual verify)
"

Logging Strategy

"Production logging:

Levels:
- ERROR: alert
- WARN: review weekly
- INFO: main flow
- DEBUG: dev only (sample %1 in prod)

Structured (JSON):
{
  "level": "info",
  "msg": "Order placed",
  "user_id": "...",
  "order_id": "...",
  "amount": 100,
  "trace_id": "...",
  "timestamp": "..."
}

Forbidden (PII):
- Email, phone, password
- Card number
- Token

Compliance:
- KVKK / GDPR
- Retention policy (90 day)
"

Detay: DevOps + AI

Debugging Mindset

"Bug investigation framework:

1. Reproduce
2. Read error literally
3. Recent changes? (git log)
4. Add logging
5. Hypothesis (en olası ilk)
6. Test hypothesis (binary search)
7. Fix
8. Verify (tests pass)
9. Regression test
10. Post-mortem (lesson learned)

Stuck > 2 saat:
- Step away (rubber duck)
- Sleep on it
- Pair with colleague
- Fresh eyes
- Document what tried
"

Yaygın Hatalar

  1. Error mesajı atlamak: %50 hint yok
  2. Random fix: Çare değil, semptom
  3. No reproduction: ‘Works on my machine’
  4. AI fix blind accept: Yan etki yok mu?
  5. No regression test: Tekrar gelir
  6. Stale dependencies suspect: Sürekli güncel değil
  7. Postmortem skip: Aynı hata tekrar

Sonraki Adımlar

Özet

Debug + AI = 5x hızlı. Stack trace 3 dk yorumla. Hipotez prioritize. Memory leak / race condition / SQL slow / browser compat — hepsi pattern. Anahtar: AI önerisini test et, root cause + regression. Senior judgement final.

Paylaş:

Yapay zeka dünyasından haberdar olun

Haftalık özet bültenimize abone olun, en yeni rehberler ve araç incelemeleri direkt e-postanıza gelsin.

İstediğiniz zaman abonelikten çıkabilirsiniz.